Received events triggered after channel is closed due to consumer_timeout (AsyncEventingBasicConsumer) #1851
Replies: 2 comments
-
The prefetched messages were delivered to the client, so it is expected that they will be passed on to the callbacks. The channel can be closed during delivery processing, by RabbitMQ or your application. Your application's state management is not a responsibility of this client. |
Beta Was this translation helpful? Give feedback.
-
They should NOT assume that, why in the world would they? In the extreme case, RabbitMQ could disappear before acking a message. If your HTTP GET request succeeds, does that automatically mean your next request will as well? Please provide code that I can clone, compile, and run, to observe this behavior. Include the necessary RabbitMQ configuration to lower the consumer timeout, and thus more easily trigger the behavior. I could do all of that, but it's time wasted that I could use to improve the behavior in this scenario.
Yes, this is the preferred method at this time. Please note that it's possible for a channel to be closed as an acknowledgement is in-flight for a message. That message will be requeued and redelivered. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
In
RabbitMQ.Client
version6.8.1
, when usingAsyncEventingBasicConsumer
withmanual acknowledgments
(autoAck = false) andprefetchCount = 50
, the client continues to triggerReceived
events even after the broker closes the channel due toconsumer_timeout
.This results in the client processing messages that it can no longer acknowledge, which leads to those messages being redelivered — even if they were already handled by the application.
Reproduction steps
AsyncEventingBasicConsumer
.Ack
for this message for a while (in the test, the timeout was lowered, but the default is 30 minutes).consumer_timeout
.Received
for the remaining prefetched messages (messages 11–50).Ack
them fails with anRabbitMQ.Client.Exceptions.AlreadyClosedException: Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text='PRECONDITION_FAILED - delivery acknowledgement on channel 1 timed out.Timeout value ....
.Expected behavior
Once the channel is closed by the broker due to
consumer_timeout
:Received
for messages that can no longer be acknowledged?Clarification on the expected behavior — and whether this has changed in newer client versions (e.g.,
7.x)
— would be appreciated.Additional context
In real-world applications, the
Received
event is often the entry point for a business transaction. Developers typically assume that if the event is fired, the message is safe to process and acknowledge.If the client continues to deliver messages after the channel has already been closed, this may lead to:
This becomes especially critical in systems that rely on at-least-once or exactly-once delivery guarantees.
Understanding whether this behavior is intentional or has been addressed in newer versions (like v7.x) would be very helpful.
Beta Was this translation helpful? Give feedback.
All reactions