AMQP Auto-ack vs Manual-ack Crash Simulator

AMQP Auto-ack vs Manual-ack Crash Simulator

animation
amqp
protocols
messaging
Try Set total messages to process to 100 and consumer crashes at message to 37.
Observe Watch how many deliveries can be retried with prefetch at 10.
Explain Explain why only 1 interrupted command might already have taken effect.

Technical boundaries. The model has one worker and assumes earlier messages were acknowledged. Auto-ack shows the minimum loss of one; only the interrupted message may already have applied a side effect.

NoteInteractive Calculator: Auto-ack vs Manual-ack Crash Simulator

Simulate consumer crashes to see how acknowledgment strategies affect message delivery.

This simplified model has one worker processing message k when its connection closes. It assumes earlier messages were acknowledged; with auto-ack, a retained queue holds later messages. With auto-ack RabbitMQ applies no prefetch limit, so a crash loses every message already pushed to the consumer; the simulator shows the minimum loss of one. Manual ack without a prefetch limit can leave every remaining delivery unacknowledged; prefetch caps the number waiting with the worker. Only message k may already have applied a side effect.

AMQP acknowledgement recovery narrated tour

Play silently with captions on provisional storyboard timing; narration audio is pending. Production pacing is not protocol time. Choose Reduced motion for a complete still at each beat.

Play the tour to open the workbench. Pause, replay a beat, or read the full transcript below. Some situations cannot be shown by this teaching model; those beats keep the existing frame and provide captions only.

Full transcript — AMQP acknowledgement recovery (8 beats)

B1 — Crash setup
You maintain the messaging service for a connected packing line. Suppose a worker program crashes while handling an equipment command. Losing that work matters, but applying the same command twice can corrupt data. How do you recover the delivery safely?

Model caption: You maintain messaging for a connected packing line. A worker program can crash during an equipment command. Lost work matters, and repeating a command can corrupt data.

B2 — Publisher confirm
Advanced Message Queuing Protocol, or AMQP, supplies rules for moving messages. A broker is the service that accepts and routes them. A publisher confirm tells the sender the broker accepted responsibility for a message. A consumer acknowledgement tells the broker that downstream processing completed.

Model caption: Advanced Message Queuing Protocol, or AMQP, moves messages through a broker that accepts and routes them. A publisher confirm reports broker acceptance. A consumer acknowledgement reports completed downstream processing.

B3 — Manual acknowledgement
With manual acknowledgement, the worker acknowledges after successful processing. Until then, the delivery stays unacknowledged. If the worker's connection closes first, the broker can put the message back in its queue for another delivery. Prefetch limits how many unacknowledged deliveries can wait with that worker.

Model caption: Acknowledge manually after successful processing. Before acknowledgement, a closed worker connection allows the broker to return the delivery to its queue. Prefetch caps unacknowledged deliveries waiting with the worker.

B4 — Unlimited retry calculation
Take the chapter's simplified example: one hundred messages, with the worker interrupted at message thirty-seven. Earlier messages were acknowledged. Without a prefetch limit, all remaining deliveries can be unacknowledged. Subtract thirty-seven from one hundred to get sixty-three. Add one for the interrupted message: sixty-four deliveries can be retried.

Model caption: Chapter model: total one hundred, crash at message thirty-seven, earlier messages acknowledged. Without a prefetch limit, subtract thirty-seven from one hundred: sixty-three. Add the interrupted message: sixty-four deliveries can be retried.

B5 — Prefetch comparison
Now set prefetch to ten. Compare ten with the sixty-four deliveries remaining, and take the smaller number: ten deliveries can be retried. In that comparison, prefetch caps how many unacknowledged deliveries return after the crash. The result concerns retries, rather than how many commands already took effect.

Model caption: Chapter calculation: compare prefetch ten with sixty-four remaining deliveries; the smaller is ten. Ten deliveries can be retried. The asset illustrates one delivery, not the batch. Retry count does not count already applied effects.

B6 — Requeue after crash
Follow the interrupted message through the crash. The broker has accepted it, and the worker has received it under manual acknowledgement. The worker's connection closes before acknowledgement arrives. The broker puts that unacknowledged message back in the queue, making it available for another delivery attempt.

Model caption: The connection closed before acknowledgement. The unacknowledged message returns to the queue, available for another delivery attempt.

B7 — Repeated effect misconception
The misconception is that manual acknowledgement makes a command take effect only once. It fails when the command takes effect before the worker crashes, but acknowledgement never arrives. The broker cannot know whether that effect happened. In our example, only the interrupted command might already have taken effect before the crash.

Model caption: Manual acknowledgement does not guarantee a single command effect. An effect may happen before a crash prevents acknowledgement. The broker cannot know whether it happened. In our example, only the interrupted command might already have taken effect before the crash.

B8 — Idempotent effects
For your command, idempotency keeps a repeated delivery from applying the same command again. The worker checks the command's identifying key before acting. It saves that key and the effect together as one update: both survive a crash, or neither is saved. Recovery retries deliveries; idempotency keeps a repeated delivery from repeating its effect.

Model caption: Idempotency keeps a repeated delivery from applying the same command again. The worker checks the command's identifying key before acting. It saves that key and the effect together as one update: both survive a crash, or neither is saved. Recovery retries deliveries; idempotency keeps a repeated delivery from repeating its effect.

Back to the chapter