Closed rbonestell closed 5 months ago
It only took one mere moment of looking back at the docs and my own existing code to realize I actually already have this stubbed out...
@SqsConsumerEventHandler('jobs.inbound', 'stopped')
Closing this issue and will chalk this up to the rubber ducky debugging process. Cheers!
I'm looking for the most effective way to gracefully handle the NestJS application lifecycle shutdown event, utilizing nestjs-sqs, while allowing my Nest app to conclude it's operation on the most recently received SQS message (often these operations are not atomic, and tend to be long-running).
I discovered the underlying sqs-consumer library [emits a
stopped
event]( ) from the privatewaitForPollingToComplete()
function once it has completed after stop() has been called on it.I would like to take advantage of this event in the
OnModuleDestroy
orOnApplicationShutdown
functions, perhaps by introducing a promise which resolves upon receiving the event such as:Would there be any reason not to want this built-in to the nestjs-sqs library and enabled with a options flag? I do understand there's additional complexity due to the library managing multiple consumers.