Repository navigation
AMQ-9118 - Wake pull consumer when a duplicate delivery is suppressed - #2761
Open
mylesmac12 wants to merge 1 commit into
Open
mylesmac12 wants to merge 1 commit into
mylesmac12 wants to merge 1 commit into
Conversation
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.
Fixes AMQ-9118
With prefetch=0 a deadlock occurs between the client and broker upon receiving a duplicate message. receive() sends the broker a pull request (asking for one message) then calls ActiveMQMessageConsumer#dequeue(-1) which sleeps (with no timeout set) until something is put in the local buffer. The broker responds with a message if available; if no message is available within the timeout the “nothing” signal is returned. Either of these messages are put in the buffer by the client, wakes the sleeping thread, and continues the loop.
During the pull of the first instance of the duplicated message, the broker sends the message, the client checks it and puts it in the buffer, the listener thread wakes, and the loop calls receive() again. During the pull of the second instance of the duplicated message, the broker sends the message again. The client notices it’s a duplicate, logs …suppressing duplicate delivery on connection, and discards the message without putting any message in the buffer. The waiting thread (from dequeue(-1)) is never woken: no “nothing” was sent (as a message was sent but discarded) and nothing appears in the buffer. The deadlock: client’s listener thread awaits something to land in the buffer, and the broker awaits the next explicit pull request.