bbc / sqs-consumer

Build Amazon Simple Queue Service (SQS) based applications without the boilerplate
https://bbc.github.io/sqs-consumer/
Other
1.72k stars 331 forks source link

fix: hold messages in a queue so another is not triggered until acknowledged #354

Closed nicholasgriffintn closed 1 year ago

nicholasgriffintn commented 1 year ago

Resolves #256

Description:

Creates an internal queue within SQS consumer, if a message in this queue we will not trigger new messages to be received until the queue is empty

Type of change:

Why is this change required?:

From the issue:

I seem to be having an issue. Let's say that I have 5 messages in my queue and I start the poller. The first message is pulled and work begins on handling it. During processing, I have a shell command that executes that can take quite awhile to return and I need the poller to wait until the previous message is completed entirely before it moves on. Unfortunately, it appears that it is only waiting the pollingWaitTimeMs time and then it is processing the next message before the previous message is done. It is even executing the message_processed callback even though the shell command has not been completed.

Code changes:

TODO:


Checklist:

codeclimate[bot] commented 1 year ago

Code Climate has analyzed commit 7986c198 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (80% is the threshold).

This pull request will bring the total coverage in the repository to 94.7% (0.4% change).

View more on Code Climate.

nicholasgriffintn commented 1 year ago

I'm not happy with this PR so I'm going to close it for now, I think adding an additional queue may cause further issues than we want and it's better to just change our advice on this instead of coding around the issue.