viewof totalMessages = Inputs.range([10, 1000], {
value: 100,
step: 10,
label: "Total messages to process:",
width: 400
})
viewof crashAt = Inputs.range([1, totalMessages], {
value: Math.floor(totalMessages * 0.37),
step: 1,
label: "Consumer crashes at message:",
width: 400
})
viewof prefetchCount = Inputs.range([1, 50], {
value: 10,
step: 1,
label: "Prefetch count (manual-ack only):",
width: 400
})
{
const autoAckLost = 1;
const autoAckStillQueued = totalMessages - crashAt;
const manualAckLost = 0;
const manualAckRedelivered = totalMessages - crashAt + 1;
const prefetchRedelivered = Math.min(prefetchCount, totalMessages - crashAt + 1);
const potentialDuplicates = 1;
const comparisonGrid = window.innerWidth < 900 ? "1fr" : "repeat(3, 1fr)";
return html`<div style="margin: 20px 0; padding: 20px; background: #f8f9fa; border-left: 4px solid #2C3E50; border-radius: 4px;">
<h4 style="margin-top: 0; color: #2C3E50;">Crash Impact Simulator</h4>
<div style="background: white; padding: 15px; border-radius: 8px; margin: 15px 0; border: 2px solid #7F8C8D;">
<div style="font-size: 14px; color: #7F8C8D; margin-bottom: 10px;">
<strong>Scenario:</strong> Processing ${totalMessages} messages, consumer crashes at message #${crashAt}
</div>
</div>
<div style="display: grid; grid-template-columns: ${comparisonGrid}; gap: 15px; margin: 15px 0;">
<div style="background: white; padding: 15px; border-radius: 8px; border: 2px solid #E74C3C;">
<div style="font-size: 12px; color: #7F8C8D; text-transform: uppercase; margin-bottom: 10px;">
Auto-ack Mode
</div>
<div style="margin: 10px 0;">
<div style="font-size: 11px; color: #7F8C8D;">Messages Lost:</div>
<div style="font-size: 32px; font-weight: bold; color: #E74C3C;">
${autoAckLost}
</div>
</div>
<div style="margin: 10px 0;">
<div style="font-size: 11px; color: #7F8C8D;">Still queued (not redelivered):</div>
<div style="font-size: 24px; font-weight: bold; color: #E67E22;">
${autoAckStillQueued}
</div>
</div>
<div style="font-size: 11px; color: #E74C3C; margin-top: 10px;">
Message #${crashAt} permanently lost (ACKed before processing completed)
</div>
</div>
<div style="background: white; padding: 15px; border-radius: 8px; border: 2px solid #16A085;">
<div style="font-size: 12px; color: #7F8C8D; text-transform: uppercase; margin-bottom: 10px;">
Manual-ack (no prefetch limit)
</div>
<div style="margin: 10px 0;">
<div style="font-size: 11px; color: #7F8C8D;">Messages Lost:</div>
<div style="font-size: 32px; font-weight: bold; color: #16A085;">
${manualAckLost}
</div>
</div>
<div style="margin: 10px 0;">
<div style="font-size: 11px; color: #7F8C8D;">Redelivered:</div>
<div style="font-size: 24px; font-weight: bold; color: #3498DB;">
${manualAckRedelivered}
</div>
</div>
<div style="font-size: 11px; color: #16A085; margin-top: 10px;">
All ${manualAckRedelivered} unacknowledged deliveries are requeued; none lost
</div>
</div>
<div style="background: white; padding: 15px; border-radius: 8px; border: 2px solid #3498DB;">
<div style="font-size: 12px; color: #7F8C8D; text-transform: uppercase; margin-bottom: 10px;">
Manual + Prefetch (${prefetchCount})
</div>
<div style="margin: 10px 0;">
<div style="font-size: 11px; color: #7F8C8D;">Messages Lost:</div>
<div style="font-size: 32px; font-weight: bold; color: #16A085;">
0
</div>
</div>
<div style="margin: 10px 0;">
<div style="font-size: 11px; color: #7F8C8D;">Potential Duplicates:</div>
<div style="font-size: 24px; font-weight: bold; color: #E67E22;">
${potentialDuplicates}
</div>
</div>
<div style="font-size: 11px; color: #3498DB; margin-top: 10px;">
Up to ${prefetchRedelivered} unacknowledged deliveries are retried; an already applied side effect may repeat
</div>
</div>
</div>
<div style="margin-top: 15px; padding: 12px; background: #fff3cd; border-radius: 6px; border-left: 3px solid #E67E22;">
<strong style="color: #E67E22;">Key Insight:</strong>
<span style="color: #2C3E50;">
In this illustrative crash at message #${crashAt}, auto-ack loses the one delivered but unfinished message.
Manual ack without a prefetch limit requeues ${manualAckRedelivered}; prefetch ${prefetchCount} caps that at ${prefetchRedelivered}.
At most ${potentialDuplicates} already applied
side effect is assumed here; use idempotency because the broker cannot know whether it happened.
</span>
</div>
</div>`;
}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.