PRECONDITION_FAILED - delivery acknowledgement on channel 1 timed out. Timeout value used: -1 ms. This timeout value can be configured, see consumers doc guide to learn more
RabbitMQ limits how long a consumer may hold a delivery without acknowledging it: consumer_timeout, 30 minutes by default. A job that runs longer, or a consumer that forgot to ack, hits it. On RabbitMQ 4.3 what happens next depends on the queue type and the client, and the error above is the rarer outcome. Measured on 4.3.6 with pika 1.4.4 and consumer_timeout = 15000 (15 seconds) to keep the waits short.
A consumer received invoice-8101 and did not ack it:
| Queue and client | After 15 seconds |
|---|---|
quorum queue, basic_consume | the broker sent basic.cancel; the channel stayed open; the message was back in the queue |
quorum queue, basic_get | channel closed with the error above; the message was back, redelivered=True |
| quorum queue, client without consumer cancel notifications | channel closed with the error above |
| classic queue, any client | nothing, still unacknowledged after six minutes |
Three details we did not expect:
basic.cancel keeps its connection and channel, looks healthy, and never receives another message. The queue shows 0 consumers.[warning] Consumer 'ctag1.82b2…' on channel 1 and queue 't3.nocancel' in vhost 'orders' has timed out waiting for a consumer acknowledgement of a delivery with
message id of 0. Timeout used: -1 ms. This timeout value can be configured, see consumers doc guide to learn more
Since RabbitMQ 4.3 the timeout applies to quorum queues only. On a classic queue we waited six minutes with a 15-second timeout and nothing happened, and the per-queue argument is refused:
PRECONDITION_FAILED - invalid arg 'x-consumer-timeout' for queue 'a.classic' in vhost 'orders' of queue type rabbit_classic_queue
A consumer-timeout policy on a classic queue is accepted and has no effect. If you relied on the timeout to free messages held by a stuck consumer, on classic queues they now stay with it until its channel closes.
Both of these set the timeout for one quorum queue, whatever the node-wide value; measured with 5 seconds, which cancelled the consumer on time. The examples give report jobs an hour:
# a policy, for queues that exist already
rabbitmqctl set_policy -p orders reports-timeout '^reports\.' '{"consumer-timeout":3600000}' --apply-to queues
# or the queue argument, at declaration
channel.queue_declare("reports.render", durable=True,
arguments={"x-queue-type": "quorum", "x-consumer-timeout": 3600000})
basic.cancel: in pika channel.add_on_cancel_callback, in the Java client handleCancel. Log it and consume again, or restart the consumer; otherwise it sits idle without anyone noticing.