Dead-letter queue
Also called: DLQ, dead letter exchange, poison message queue.
A side queue where a message goes after it has failed a set number of times, so one broken message stops looping in the main queue. You inspect it, fix the bug and send it back (redrive).
Send a few emails and one bad one. The bad one fails 3 times, then moves to the dead-letter queue, so it stops looping and the others keep going. The prompt says 5 tries; the demo uses 3 to keep it short.
Sent: 0 · In the queue: 0 · In the DLQ: 0
The queue is empty. Each message gets up to 3 tries (maxReceiveCount 3).
Say it in a prompt
Give the emails queue a dead-letter queue: after 5 failed receives (maxReceiveCount 5), move the message to emails-dlq. Keep DLQ messages for 14 days, alert as soon as the DLQ is not empty, and add an admin command that redrives its messages to the main queue after a fix. Vague vs precise prompt
Vague prompt
some jobs fail and retry forever, stop that Typical resultWraps the handler in try/catch and quietly drops the job on any error. The failed emails are gone and nobody knows.
Precise prompt
Add a dead-letter queue: after 5 failed receives (maxReceiveCount 5), move the message to emails-dlq. Keep it 14 days, alert when the DLQ is not empty, and add a command to redrive messages after a fix. Typical resultA broken message stops after 5 tries instead of looping, nothing is lost, someone gets alerted, and the fixed messages replay with one command.
Seen on
- Amazon SQS: A redrive policy's maxReceiveCount sets how many times a message can be received before SQS moves it to the dead-letter queue; redrive moves messages back out.
- RabbitMQ: Dead-letters a message that is rejected without requeue, expires by TTL, overflows the queue's length limit, or passes a quorum queue's delivery limit.
You might describe it as
- a bad message keeps crashing the worker over and over
- put the failed jobs aside to look at later
- where messages go after too many retries
Not to be confused with
- Queue
The dead-letter queue only receives messages that failed too many times; the main queue holds the normal work.