viewof durableQueue = Inputs.select(["false", "true"], {
label: "Queue durable:",
value: "true"
})
viewof deliveryMode = Inputs.select(["1 (transient)", "2 (persistent)"], {
label: "Message delivery_mode:",
value: "1 (transient)"
})
viewof msgCountInQueue = Inputs.range([100, 50000], {
value: 5000,
step: 100,
label: "Messages in queue at restart:",
width: 400
})Try It: Persistence Configuration Tester
Try It: Persistence Configuration Tester
animation
amqp
protocols
messaging
Try Change message delivery_mode to 2 (persistent) with queue durable set to true.
Observe Watch After Restart, Configuration Status, and Data Loss after Play restart.
Explain Explain why delivery_mode 2 requires a durable queue for messages to survive.
Technical boundaries. Restart survival depends only on queue durability and message delivery mode. All messages survive when both settings are required values; otherwise all messages are lost.
NoteTry It: Persistence Configuration Tester
Select different combinations of queue durability and message delivery mode to see what survives a broker restart. Watch the visual queue fill and drain to build intuition for why both settings are required.
{
const isDurable = durableQueue === "true";
const isPersistent = deliveryMode.startsWith("2");
const queueSurvives = isDurable;
const msgsSurvive = isDurable && isPersistent;
const msgsAfter = msgsSurvive ? msgCountInQueue : 0;
const lossPercent = msgsSurvive ? 0 : 100;
const configLabel = isDurable && isPersistent ? "SAFE" :
isDurable && !isPersistent ? "TRAP (most common mistake!)" :
!isDurable && isPersistent ? "POINTLESS (no queue to hold them)" :
"TOTAL LOSS";
const configColor = msgsSurvive ? "#16A085" : "#E74C3C";
const barWidth = 320;
const beforeFill = barWidth;
const afterFill = msgsSurvive ? barWidth : 0;
return html`<div style="margin: 20px 0; padding: 20px; background: #f8f9fa; border-left: 4px solid ${configColor}; border-radius: 4px; overflow-x: auto;">
<h4 style="margin-top: 0; color: #2C3E50;">Broker Restart Simulation</h4>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin: 15px 0;">
<div style="background: white; padding: 15px; border-radius: 8px;">
<div style="font-size: 12px; color: #7F8C8D; text-transform: uppercase; margin-bottom: 8px;">Before Restart</div>
<div style="font-size: 14px; color: #2C3E50; margin-bottom: 6px;">Queue: <strong>${msgCountInQueue.toLocaleString()}</strong> messages</div>
<div style="background: #ecf0f1; border-radius: 4px; height: 24px; width: ${barWidth}px; overflow: hidden;">
<div style="background: #3498DB; height: 100%; width: ${beforeFill}px; border-radius: 4px; transition: width 0.5s;"></div>
</div>
</div>
<div style="background: white; padding: 15px; border-radius: 8px;">
<div style="font-size: 12px; color: #7F8C8D; text-transform: uppercase; margin-bottom: 8px;">After Restart</div>
<div style="font-size: 14px; color: ${configColor}; margin-bottom: 6px;">Queue: <strong>${msgsAfter.toLocaleString()}</strong> messages ${!queueSurvives ? "(queue gone)" : ""}</div>
<div style="background: #ecf0f1; border-radius: 4px; height: 24px; width: ${barWidth}px; overflow: hidden;">
<div style="background: ${configColor}; height: 100%; width: ${afterFill}px; border-radius: 4px; transition: width 0.5s;"></div>
</div>
</div>
</div>
<div style="text-align: center; margin: 15px 0; padding: 15px; background: white; border-radius: 8px; border: 2px solid ${configColor};">
<div style="font-size: 14px; color: #7F8C8D;">Configuration Status</div>
<div style="font-size: 22px; font-weight: bold; color: ${configColor}; margin: 8px 0;">${configLabel}</div>
<div style="font-size: 14px; color: #2C3E50;">
durable=${durableQueue}, delivery_mode=${isPersistent ? "2" : "1"}
</div>
<div style="font-size: 13px; color: #7F8C8D; margin-top: 8px;">
${!isDurable && !isPersistent ? "Neither queue nor messages survive. Everything is lost." :
isDurable && !isPersistent ? "Queue survives but arrives EMPTY. 68% of deployments make this mistake." :
!isDurable && isPersistent ? "Messages are written to disk but the queue definition is lost, so they cannot be recovered." :
"Both queue definition and message data survive the restart. Zero data loss."}
</div>
</div>
<div style="margin-top: 15px; padding: 12px; background: ${msgsSurvive ? '#e8f8f5' : '#fdedec'}; border-radius: 6px; border-left: 3px solid ${configColor};">
<strong style="color: ${configColor};">Data Loss:</strong>
<span style="color: #2C3E50;"> ${lossPercent}% (${(msgCountInQueue - msgsAfter).toLocaleString()} messages lost)</span>
</div>
</div>`;
}