Skip to content

Fix consumer stuck after multiple failovers (AMQ-5915 equivalent)#56

Merged
blackb1rd merged 5 commits into
mainfrom
fix-amq-failover-consumer-resume-14382797117806031016
May 11, 2026
Merged

Fix consumer stuck after multiple failovers (AMQ-5915 equivalent)#56
blackb1rd merged 5 commits into
mainfrom
fix-amq-failover-consumer-resume-14382797117806031016

Conversation

@blackb1rd
Copy link
Copy Markdown
Owner

When an activemq server fails over repeatedly (active/passive), the C++ client library fails to resume consuming messages until the application is restarted.
This is similar to AMQ-5915 on the Java ActiveMQ client. The issue is caused by inProgressClearRequiredFlag being incremented multiple times due to multiple transport interruptions. The clearMessagesInProgress method was originally using fetch_sub(1), which didn't fully clear the flag back to 0, leaving the consumer stuck. In addition, the method was missing a call to clearDeliveredList().

This fix changes fetch_sub(1) to store(0) and adds the missing clearDeliveredList() to correctly reset the consumer's state.


PR created automatically by Jules for task 14382797117806031016 started by @blackb1rd

Ported fix from AMQ-5915 (Java ActiveMQ client) to the C++ client.
Modified `ActiveMQConsumerKernel::clearMessagesInProgress` to correctly
reset `inProgressClearRequiredFlag` to 0 instead of decrementing it.
Also added the missing `clearDeliveredList()` call to ensure that
delivered messages are properly cleared when transport is interrupted
during a failover.

Co-authored-by: blackb1rd <2668486+blackb1rd@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 4 commits May 8, 2026 01:44
Ported fix from AMQ-5915 (Java ActiveMQ client) to the C++ client.
Modified `ActiveMQConsumerKernel::clearMessagesInProgress` to correctly
reset `inProgressClearRequiredFlag` to 0 instead of decrementing it.
Also added the missing `clearDeliveredList()` call to ensure that
delivered messages are properly cleared when transport is interrupted
during a failover.

A test case `testClearMessagesInProgressFlag` has been added to
`ActiveMQSessionTest.cpp` to verify that consumers can correctly resume
and receive messages even after experiencing multiple consecutive
transport interruptions.

Co-authored-by: blackb1rd <2668486+blackb1rd@users.noreply.github.com>
Signed-off-by: Prachya Saechua <psaechua@cpaxtra.co.th>
Ported fix from AMQ-5915 (Java ActiveMQ client) to the C++ client.
Modified `ActiveMQConsumerKernel::clearMessagesInProgress` to correctly
reset `inProgressClearRequiredFlag` to 0 instead of decrementing it.
Also added the missing `clearDeliveredList()` call to ensure that
delivered messages are properly cleared when transport is interrupted
during a failover.

A test case `testClearMessagesInProgressFlag` has been added to
`ActiveMQSessionTest.cpp` to verify that consumers can correctly resume
and receive messages even after experiencing multiple consecutive
transport interruptions. This commit also ensures clang-format passes.

Co-authored-by: blackb1rd <2668486+blackb1rd@users.noreply.github.com>
Ported fix from AMQ-5915 (Java ActiveMQ client) to the C++ client.
Modified `ActiveMQConsumerKernel::clearMessagesInProgress` to correctly
reset `inProgressClearRequiredFlag` to 0 instead of decrementing it.
Also added the missing `clearDeliveredList()` call to ensure that
delivered messages are properly cleared when transport is interrupted
during a failover.

A test case `testClearMessagesInProgressFlag` has been added to
`ActiveMQSessionTest.cpp` to verify that consumers can correctly resume
and receive messages even after experiencing multiple consecutive
transport interruptions. This commit also ensures clang-format passes.

Co-authored-by: blackb1rd <2668486+blackb1rd@users.noreply.github.com>
@blackb1rd blackb1rd merged commit 960d4d5 into main May 11, 2026
102 checks passed
@blackb1rd blackb1rd deleted the fix-amq-failover-consumer-resume-14382797117806031016 branch May 11, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants