Fin W
Fin W

Reputation: 43

Why am I only getting one message from my SQS Queue?

ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueURL);

List<com.amazonaws.services.sqs.model.Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();

Whenever I try and pull all of the messages from my SQS queue, the size of the 'messages' list is always 1. How do I ensure that every item in the queue is added to that list?

Any advise would be appreciated!

Upvotes: 4

Views: 3287

Answers (1)

jarmod
jarmod

Reputation: 78842

You need to supply the maximum number of messages to return. Amazon SQS never returns more messages than this value (however, fewer messages might be returned). Valid values are 1 to 10. Default is 1.

See setMaxNumberOfMessages(Integer maxNumberOfMessages).

Upvotes: 4

Related Questions