What is a Dead-letter Queue?
A dead-letter queue, told as a story about a small box set aside for orders that keep failing.
One order keeps failing, so it just keeps getting retried.It can't recognize the ingredient name.
Why: retrying a broken order forever jams the whole line.Everyone behind is stuck.
An order that keeps failing gets set aside, so the rest keep flowing.The set-aside ones get checked by a person later.
A small unclaimed box beside the normal basket — moved there after ×3 retries.After a few more tries, it's set aside for a person to check.
An unclaimed box nobody checks is as good as discarded.Someone must check it regularly.
A dead-letter queue: a separate box for orders that fail even after retries — so the rest of the line keeps flowing, unblocked.
You set a cap on retries, and move any message past that cap (a poison message) here. Setting it aside isn't the end — wire up an alert so a person sees it, fix the cause, and reprocess it. Reprocessing safely requires idempotency.
When grown-ups say it
- Dead-letter Queue
- The basket nobody came to claim. A separate place for messages that keep failing.
- Max Retry Count
- The number of retries decided on in advance. Past this, the message moves to the dead-letter queue.
- Message Queue
- The basket that holds order slips. → the basket that holds the order slips
- Poison Message
- A message that keeps failing no matter what. It goes to the dead-letter queue once it exceeds the retry cap.
- Alerting
- Notifying a person when something lands in the box. → how many rings mean a real emergency
- Reprocessing
- Fixing the cause and putting the message back in the queue. Putting it back blindly can just fail again.
- Idempotency
- The property that lets you safely resend the same thing. Essential when reprocessing. → you can't ride twice on the same ticket
- Observability
- The ability to look inside the baskets and boxes. → looking in through three kinds of signals