feat: Improve graceful shutdown for inline processor, rmq, and sqs#2322
Closed
benjamin-alexander-simplisafe wants to merge 2 commits intoJasperFx:mainfrom
Closed
feat: Improve graceful shutdown for inline processor, rmq, and sqs#2322benjamin-alexander-simplisafe wants to merge 2 commits intoJasperFx:mainfrom
benjamin-alexander-simplisafe wants to merge 2 commits intoJasperFx:mainfrom
Conversation
…spose Adds latching and draining for the inline receiver, waiting for already started messages to complete processing and deferring any that haven't. Fixes a bug in ListeningAgent where a ReceiverWithRules won't latch the wrapped receiver. Updates RmqListener to only stop consuming, and not dispose of the consumer, so the channel stays around for acking/nacking/deferring in-progress messages instead of forcing redelivery. Updates SqsListener to cancel the polling loop on StopAsync instead of immediately disposing the client and abandoning in-flight messages till the visibility timeout expires.
Comment on lines
+45
to
+51
| // If _latched was already true, this drain was triggered during shutdown | ||
| // (after OnApplicationStopping called Latch()). Safe to wait for in-flight items. | ||
| // If _latched was false, this drain may have been triggered from within the handler | ||
| // pipeline (e.g., rate limiting pause via PauseListenerContinuation). Waiting for | ||
| // in-flight items to complete would deadlock because the current message's | ||
| // execute function is still on the call stack. | ||
| var waitForCompletion = _latched; |
Contributor
Author
There was a problem hiding this comment.
This was replicated from the other receivers, and I think is necessary here too.
jeremydmiller
added a commit
that referenced
this pull request
Mar 22, 2026
…and SQS Incorporates changes from benjamin-alexander-simplisafe's PR to improve graceful shutdown behavior for inline message processing, RabbitMQ, and Amazon SQS transports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
jeremydmiller
added a commit
that referenced
this pull request
Mar 22, 2026
Upgrade JasperFx + integrate graceful shutdown improvements from PR #2322
Member
|
@benjamin-alexander-simplisafe Hey, this got brought in through a different branch, but it'll be in 5.22 shortly. Thank you for contributing this! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi there. We've recently started using Wolverine for a queue processor that, for various reasons, we need to use with inline mode. This fixes a couple issues we've noticed with it. Admittedly some of the understanding of how this works was Claude assisted so i hope nothing's too off base.
Adds latching and draining for the inline receiver, waiting for already started messages to complete processing and deferring any that haven't. Also added tests for this behavior. This avoids unnecessary re-processing and delays (especially when used with aws sqs).
The following I don't seen any tests covering the existing behavior, so I held off on adding any for now. Let me know if you think it makes sense to add some.
InlineReceivers. Also fixes a bug (i think) where a ReceiverWithRules won't latch the wrapped receiver. If this is unnecessary for some reason I can revert it out.