A safe place for messages that keep failing, so they do not block everyone else.
A dead letter queue (DLQ) is a side queue for messages that could not be processed, even after several retries.
Some messages can never succeed. The data may be broken, a field may be missing, or a bug may crash the code. Retrying them forever wastes work. A poison message is one that fails every time.
Most queue and broker products have this idea built in (for example Amazon SQS redrive policies, RabbitMQ dead-letter exchanges, Google Pub/Sub dead letter topics). Exact settings differ by product.
| Reason | Kind | Retry helps? |
|---|---|---|
| Partner API is down for a minute | Temporary | Yes. Retry later with backoff. |
| Database is busy or timed out | Temporary | Yes. |
| Message has invalid JSON or a missing field | Permanent (poison) | No. It will never work. Send to the DLQ at once. |
| Bug in the consumer code | Permanent until fixed | No. Fix the code, then redrive. |
| Business rule fails (customer not found) | Permanent | Usually no. |
Wait longer after each failure. This gives a struggling service time to recover. Add a little random delay (jitter) so many consumers do not retry together.
| Term | Meaning in easy words |
|---|---|
| Dead letter queue (DLQ) | A queue for messages that could not be processed |
| Poison message | A message that fails every time it is tried |
| Retry limit | How many tries before a message is moved to the DLQ |
| Backoff | Waiting longer between retries |
| Jitter | Random extra delay so retries do not all happen together |
| Redrive | Moving messages from the DLQ back to the main queue |
| Transient error | A temporary problem that may go away |
| Permanent error | A problem that retrying will not fix |
| Queue depth | How many messages are waiting |
| Alarm | An automatic alert when a number crosses a limit |
| Choice | We gain | We lose |
|---|---|---|
| Few retries | Fast move to DLQ, quick signal | May give up on a temporary error |
| Many retries | Rides out longer outages | Slow failure, more load |
| Auto redrive | Less manual work | May loop if the bug is not fixed |
| Manual redrive | Safe and controlled | Needs a person |