sqs-consumer icon indicating copy to clipboard operation
sqs-consumer copied to clipboard

Change polling waiting time dynamically

Open ricardoribas opened this issue 3 years ago • 0 comments

The problem In order to reduce the number of empty receives, i would like to open a discussion here about adding this feature. We have knowledge about the number of messages received upon each request to SQS. With that in mind we can increase/decrease the polling wait time accordingly.

Suggested solution We can activate this feature using a new flag or we can automatically calculate this new wait time. As soon we receive an empty message, we can increase the polling time using a function that will increase 1 second (1000 ms) until we reach a maximum threshold. The same applies when we receive messages. We will decrease the polling wait time until we reach the original value on the constructor (or 0 as the default value)

Alternatives considered Having the polling wait time ms public so we can change this value outside. Or we can have a method to update this value.

ricardoribas avatar Feb 02 '22 13:02 ricardoribas