I am developing an application where I am using Amazon SQS. I am new to AWS, so I have one small doubt regarding receiving messages from an SQS. I have configured an SQS and want to receive messages from it by using long polling. My question is how many numbers of messages I can get from the SQS in max?
I have set the MaxNumberOfMessages to 50 and the ReceiveMessageWaitTimeSeconds to 20.
Q1. Shall I get a max of 50 messages from the SQS?
Q2. How does ReceiveMessageWaitTimeSeconds matter? I read in the AWS documentation that short polling is = 0 sec and long polling is anything more than 0 second. Does it mean that I can set ReceiveMessageWaitTimeSeconds = 5 also to ensure long polling?
I also read the difference between short polling and long polling as the former one will only query a subset of SQS servers and the latter will query all the servers. So does the seconds matter except the fact that it will wait for 5 seconds or 20 seconds?
I have gone through the below AWS docs:
The sample code is given below:
CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName);
String queueUrl = sqs.createQueue(createQueueRequest).getQueueUrl();
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);
receiveMessageRequest.setMaxNumberOfMessages(50);
receiveMessageRequest.setReceiveMessageWaitTimeSeconds(20);
List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
for (Message message : messages) {
// I'm a message from SQS
}