1 Answer
- Newest
- Most votes
- Most comments
0
When reading from SQS you can't define a window size and the maximum buffer size that you can configure is 10 messages. Just use LongPolling with 10 messages. When the messages will become available. it will return the messages. It will not wait for 20 seconds.
The only caveat is that if there is a very small number of messages in the queue, due to the distributed nature of SQS, you may not get the messages immediately, regardless of the batch size. When you have many messages, it will not happen.
Relevant content
- asked a year ago
- asked 5 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 8 months ago
thank you for your answer, if i have a batch size with 10 messages and let's say in the queue there are only 4 messages will consume those 4 messages immediately? or long polling will wait till it gets a total of 10 messages or the wait time for long polling been elapsed
The batch size is the maximum messages to retrieve, not the number of messages to wait for. This means that if the there are less messages in the queue, you will get them. However, as I wrote before, in some edge cases, when there is low traffic in the queue and small number of messages, you may wait for 20 seconds and get an empty batch, even though there are messages in the queue. If you have more than one consumer, the chance of this happening, reduces.