Repository navigation
Respond with basic.cancel-ok to the servers that support it - #2113
Merged
Merged
Conversation
If the server advertises `basic.cancel-ok` response support. The background on this is this: starting with `4.3.0`, a delivery acknowledgement timeout does not result in the channel being closed but rather a `basic.cancel` sent to the client. Between about 2011 and 2026, clients never had the need to respond to such `basic.cancel` because it was originally a client method. Unfortunately, RabbitMQ versions between `4.3.0` and `4.3.6` only clean up the consumer after a `basic.cancel-ok` arrives but older versions cannot handle `basic.cancel-ok`, hence the new capability and the conditional confirmation.
michaelklishin
force-pushed
the
mk-basic-cancel-ok-server-capability
branch
from
October 6, 2026 01:30
a50d7af to
1c9a5c0
Compare
…ered client callback
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new test helper contains a race that can discard the simulated response and hang the test suite.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds capability-gated basic.cancel-ok responses for server-initiated consumer cancellation.
Changes:
- Introduces server capability detection
- Sends conditional cancellation acknowledgements
- Adds capability and channel behavior tests
| File | Description |
|---|---|
ServerCapability.java |
Defines advertised server capabilities |
AMQConnection.java |
Detects server capability support |
ChannelN.java |
Sends conditional basic.cancel-ok responses |
AMQConnectionCapabilitiesTest.java |
Tests capability detection |
ChannelNTest.java |
Tests cancellation response behavior |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+169
to
+177
| new Thread(() -> { | ||
| try { | ||
| Thread.sleep(15); | ||
| channel.handleCompleteInboundCommand( | ||
| new AMQCommand(new AMQImpl.Basic.ConsumeOk(consumerTag))); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| }).start(); |
acogoluegnes
approved these changes
Oct 6, 2026
Contributor
Author
|
Thank you, @acogoluegnes. |
Contributor
Author
|
@Mergifyio backport v5.x |
✅ Backports have been createdDetails
Cherry-pick of 1c9a5c0 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
michaelklishin
added a commit
that referenced
this pull request
Oct 6, 2026
Respond with `basic.cancel-ok` to the servers that support it (backport #2113)
This was referenced Oct 7, 2026
suchitd
added a commit
to rabbitmq/rabbitmq-dotnet-client
that referenced
this pull request
Oct 7, 2026
Starting with RabbitMQ 4.3.0, a delivery acknowledgement timeout cancels the consumer with a broker-sent `Basic.Cancel` instead of closing the channel, and the broker expects a `Basic.CancelOk` reply. Brokers older than 4.3.0 do not accept the reply, so only reply to brokers that advertise the `accept_consumer_cancel_ok` capability. For more details, see rabbitmq/rabbitmq-server#17734 and rabbitmq/rabbitmq-java-client#2113.
suchitd
added a commit
to rabbitmq/rabbitmq-dotnet-client
that referenced
this pull request
Oct 7, 2026
Starting with RabbitMQ 4.3.0, a delivery acknowledgement timeout cancels the consumer with a broker-sent `basic.cancel` instead of closing the channel, and the broker expects a `basic.cancel-ok` reply. Brokers older than 4.3.0 do not accept the reply, so only reply to brokers that advertise the `accept_consumer_cancel_ok` capability. For more details, see rabbitmq/rabbitmq-server#17734 and rabbitmq/rabbitmq-java-client#2113.
JadeCong
pushed a commit
to CloudEngineHub/pika
that referenced
this pull request
Oct 8, 2026
Starting with RabbitMQ 4.3.0, a delivery acknowledgement timeout cancels the consumer with a broker-sent `Basic.Cancel` instead of closing the channel, and the broker expects a `Basic.CancelOk` reply. Brokers older than 4.3.0 do not accept the reply, so only reply to brokers that advertise the `accept_consumer_cancel_ok` capability. For more details, see rabbitmq/rabbitmq-server#17734 and rabbitmq/rabbitmq-java-client#2113.
lukebakken
pushed a commit
to rabbitmq/rabbitmq-dotnet-client
that referenced
this pull request
Oct 8, 2026
Starting with RabbitMQ 4.3.0, a delivery acknowledgement timeout cancels the consumer with a broker-sent `basic.cancel` instead of closing the channel, and the broker expects a `basic.cancel-ok` reply. Brokers older than 4.3.0 do not accept the reply, so only reply to brokers that advertise the `accept_consumer_cancel_ok` capability. For more details, see rabbitmq/rabbitmq-server#17734 and rabbitmq/rabbitmq-java-client#2113.
suchitd
added a commit
to rabbitmq/rabbitmq-dotnet-client
that referenced
this pull request
Oct 12, 2026
Starting with RabbitMQ 4.3.0, a delivery acknowledgement timeout cancels the consumer with a broker-sent `basic.cancel` instead of closing the channel, and the broker expects a `basic.cancel-ok` reply. Brokers older than 4.3.0 do not accept the reply, so only reply to brokers that advertise the `accept_consumer_cancel_ok` capability. For more details, see rabbitmq/rabbitmq-server#17734 and rabbitmq/rabbitmq-java-client#2113.
suchitd
added a commit
to rabbitmq/rabbitmq-dotnet-client
that referenced
this pull request
Oct 14, 2026
Starting with RabbitMQ 4.3.0, a delivery acknowledgement timeout cancels the consumer with a broker-sent `basic.cancel` instead of closing the channel, and the broker expects a `basic.cancel-ok` reply. Brokers older than 4.3.0 do not accept the reply, so only reply to brokers that advertise the `accept_consumer_cancel_ok` capability. For more details, see rabbitmq/rabbitmq-server#17734 and rabbitmq/rabbitmq-java-client#2113.
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.

If the server advertises
basic.cancel-okresponse support.The background on this is this: starting with
4.3.0, a delivery acknowledgement timeout does not result in the channel being closed but rather abasic.cancelsent to the client.Between about 2011 and 2026, clients never had
the need to respond to such
basic.cancelbecause it was originally a client-sent methodand with consumer cancel notifications (an AMQP 0-9-1 extension), the client-sent confirmation was never required or expected.
Unfortunately, RabbitMQ versions between
4.3.0and
4.3.6only clean up the consumer aftera
basic.cancel-okarrives but older versionscannot handle
basic.cancel-ok, hence the newcapability and the conditional confirmation.
The Server Part of the Changes
See rabbitmq/rabbitmq-server#17734 for what's being
changed on the server to restore compatibility with older clients.