Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 233
Fin W Avatar asked Oct 28 '25 02:10

Fin W


1 Answers

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).

like image 121
jarmod Avatar answered Oct 29 '25 18:10

jarmod