Reputation: 680
I have a standard AWS SQS with 13 messages. I wrote a simple JavaScript function to fetch 10 messages using long polling.
Here is the code:
/* aws config */
Poller.prototype.poll = async function() {
let response;
try{
response = await this.SQS.receiveMessage({
QueueUrl: "https://sqs.region.amazonaws.com/user_id/queue_name",
MaxNumberOfMessages: 10,
VisibilityTimeout: 20,
WaitTimeSeconds: 20
}).promise();
return response;
} catch(err) {
console.log('its an error');
/* handel error */
}
}
Every time i run this code it returns 2 messages and then 4 and this continues. I have tried messing with the WaitTimeSeconds
and VisibilityTimeout
but no use.
I am new to AWS SQS, thanks in advance. :)
Upvotes: 1
Views: 374
Reputation: 46841
That is not unusual behavior - you are actually specifiying 'upto' 10 messages max, in my experience, unless a queue has lots of records (hundreds/thousands or more), than the small number returned is to be expected.
Upvotes: 2