Closed cassiolacerda closed 8 months ago
@ssut This feature is very helpful, especially if you have a limited graceful shutdown time, which is common in applications running in Kubernetes clusters. I would be grateful if you consider this Pull Request.
Thanks for your contribution through this PR. I'm preparing for a new release that will include this PR, fixing tests, and bump up some deps. As my availability these days is limited during the weekdays, it'll take a sec.
Context
The
bbc/sqs-consumer
library gives support for stop options, where it's possible to abort immediately a consumer without await for polling to complete.Problem
Currently, the
ssut/nestjs-sqs
doesn't give support to set these options and call stop method without any params. Abort behaviour is an important option in a graceful shutdown strategy and it would be a good improvement for the lib support that too.Solution
The stop options can be used in a global and / or consumer specific approach:
globalStopOptions
Enable stopping of all registered consumers immediately after shutdown.stopOptions
Enable stopping of specific consumers immediately after shutdown.globalStopOptions
+stopOptions
Enable stopping of all registered consumers immediately after shutdown, except consumerqueue-1
because itsstopOptions
override theglobalStopOptions
.⚠️ Important: I was unable to add any tests because I had problems running the tests locally.