When I send multiple messages to my SQS and read it like
//Sending message to queue
SendMessageRequest smr = new SendMessageRequest(queueUrl, "one");
sqs.sendMessage(smr);
smr = new SendMessageRequest(queueUrl, "two");
sqs.sendMessage(smr);
smr = new SendMessageRequest(queueUrl, "three");
sqs.sendMessage(smr);
Thread.sleep(5000);
//Reading Queue
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);
List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
I have only one message in my List.
When I repeat the "Reading Queue" for the second time, I get the second message and I when repeat that for the third time I get the third message. The messages being retrieved from queue are in random order. But why am I not getting all the 3 messages in the List<messages>
?