-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Wait for msgs to be processed before emitting stopped #454
Conversation
updates pushed |
Notes:
With a similar check for stopping to this: https://github.com/bbc/sqs-consumer/blob/main/src/consumer.ts#L126 Then we might want to adjust this function to return all three states: https://github.com/bbc/sqs-consumer/blob/main/src/consumer.ts#L151 (This comment would make it breaking though, so maybe for the future...) |
Thanks for this PR btw! Looking good! |
CLA Assistant Lite bot CLA CHECK All Contributors have signed the CLA |
Code Climate has analyzed commit bbfb1cc 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 98.3% (0.0% change). View more on Code Climate. |
…Ms and move to constructor
I have read the CLA Document and I hereby sign the CLA |
Thanks for the feedback, @nicholasgriffintn - I've pushed changes that I think address all the requests, but left one clarification question about the date stuff. I like your suggestion in #454 (comment) but I agree it may be nice as a follow up for later since it would be a breaking change |
This is looking good btw, sorry for the delay, it's on my list :). |
All good, thanks! |
Resolves #410
Description:
Optionally delay the
emit('stopped')
event until in-flight messagesfrom the most recent poll have been processed.
Thank you for creating and maintaining a great module.
sqs-consumer
has beenpleasant tool to work with.
I'm entirely open to other suggestions of how to address the problem. Maybe I'm missing something that already exists to accomplish this. Thanks in advance.
Type of change:
Why is this change required?:
We are implementing a graceful shutdown of queue consumers just before issuing a process.exit() in our app
I'd like to support waiting for in-flight messages to be finalized before exiting, but it seems
the current implementation emits
stopped
without that guarantee.Code changes:
pollingCompleteWaitTimeMs
option forConsumer.create()
to enable the waiting behavior on shutdown.Consumer.waitForPollingToComplete()
that loops with 1s delay until all messages are processed, when feature is enabled. The currentConsumer.stop()
method would use this to facilitate the waiting prior to emittingstopped
Checklist: