Android-从AWS SQS获取消息 [英] Android - Getting messages from AWS SQS
问题描述
我具有从AWS SQS返回消息的功能:
I have function which returns messages from AWS SQS:
public List<Message> getMessagesFromQueue(String queueUrl){
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);
List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
return messages;
}
问题在于它每次都返回不同数量的消息,而不是我队列中的所有4条消息.
The problem is that it returns different number of messages each time, never all 4 which I have in the queue.
推荐答案
很遗憾听到您在使用API来使用API读取SQS队列时遇到困难.您可以在以下位置找到Java客户端提供的receiveMessage文档:
I am sorry to hear that you are having difficulty using the API to achieve reading the SQS queue using the API. You can find the documentation for receiveMessage from the Java client here:
The documentation for receiveMessage indicates that anywhere from 1 to 10 messages may be returned. The number returned may be limited by calling the setMaxNumberOfMessages method on the ReceiveMessageRequest object; however, this only limits the maximum amount of messages that may be returned. To attempt to read all the messages in the queue, try calling the method until no messages come back in the response.
这篇关于Android-从AWS SQS获取消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!