consumer_timeouts.md
Consumer timeouts (also known as "message locks") limit how long a consumer can hold unacknowledged messages before RabbitMQ takes action.
Note: Consumer timeouts are only supported for quorum queues. Classic queues and stream queues do not support consumer timeouts.
When a consumer receives a message in manual acknowledgement mode, it has a limited time to acknowledge (or reject) the message. If the timeout expires before the message is settled, RabbitMQ:
Consumer timeouts can be configured at four levels:
Set via the x-consumer-timeout argument when creating a consumer (in milliseconds):
#'basic.consume'{arguments = [{<<"x-consumer-timeout">>, long, 60000}]}
This takes absolute precedence over all other settings.
Set via the x-consumer-timeout argument when declaring a queue (in milliseconds):
#'queue.declare'{arguments = [{<<"x-consumer-timeout">>, long, 60000}]}
Set via a policy with the consumer-timeout key (in milliseconds):
rabbitmqctl set_policy consumer-timeout-policy ".*" \
'{"consumer-timeout": 60000}' --apply-to quorum_queues
Note: When both a queue argument and a policy are set, the minimum of the two values is used.
Set in rabbitmq.conf:
consumer_timeout = 1800000
Default: 1,800,000 milliseconds (30 minutes)
x-consumer-timeout on basic.consume) - if set, used directlyconsumer_timeout configuration| Queue Type | Consumer Timeout Support |
|---|---|
| Quorum queues | Full support |
| Classic queues | Not supported |
| Stream queues | Not supported |
In RabbitMQ 4.2.x and earlier, consumer timeouts always closed the channel with a precondition_failed error, regardless of client capabilities. This was disruptive as it terminated all consumers on the channel, not just the one that timed out.
Starting with RabbitMQ 4.3, the behaviour is more graceful for clients that support the consumer_cancel_notify capability (which most modern clients do). Instead of closing the channel, the server sends a basic.cancel notification to cancel only the timed-out consumer, leaving the channel and other consumers intact.
Clients that do not advertise the consumer_cancel_notify capability will still experience channel closure on timeout, maintaining backwards compatibility.
When a consumer timeout occurs on a quorum queue:
When a timeout occurs, the server notifies the client using protocol-specific mechanisms:
consumer_cancel_notify capability: Server sends basic.cancel to the consumer, channel remains openconsumer_cancel_notify capability: Server closes the channelOptions under consideration (in order of preference):
released outcome (§3.4.4), if client supports itRabbitMQ uses relatively long message locks (default 30 minutes) without lock renewal, unlike some other message brokers. For comparison, Azure Service Bus defaults to 1-minute locks with a 5-minute maximum, requiring explicit lock renewal.
This design choice reflects that:
If lock renewal were to be supported in the future, one option for AMQP 1.0 would be to use the received outcome as a heartbeat mechanism to renew message locks. The received outcome is non-terminal and can be sent multiple times. However, this would need careful design to avoid conflicts with its primary use case for resumable large message transfers.