Latch receiver after stopping listener on shutdown#2391
Merged
jeremydmiller merged 2 commits intoJasperFx:mainfrom Mar 31, 2026
Merged
Conversation
This avoids deferring messages during shutdown, which current happens when the listener receives messages after the receiver is latched.
This should speed up the shutdown process in general (and, importantly, means that the previous commit won't stall shutdown by waiting to latch listener B until listener A is stopped and drained. Technically this was a risk before, but since deferring messages is a fast operation it wasn't as important). This should be safe, since each StopAsync is wrapped in a try-catch. Also updated the ParallelListener to stop children in parallel, which avoids one error from preventing other attempts (similar to the CompoundListener) and should further speed things up.
Member
|
@benjamin-alexander-simplisafe Hey, I'm going to try to get this in for the next release, but as I'm sure you completely understand, I need to review this one carefully! |
This was referenced Apr 1, 2026
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.
Currently, wolverine latches all receivers immediately when shutdown is requested. This means that any messages consumed by listeners after that happens are deferred, which (for the same reasons as in #2347) can have poor performance characteristics.
This change moves latching each receiver to after its respective listener is stopped, so all consumed messages get a fair shot at being processed.
This also moves to shutting down the listeners in parallel so that they don't wait to latch before the previous ones finish shutting down. This was also done to the ParallelListener, with similar exception aggregation to the CompoundListener. I think this is a general improvement to the shutdown flow, but also avoids extra bad behavior from moving latching.