Services

Resources

Company

DLQ (dead letter queue)

A dead letter queue (DLQ) is a separate queue or topic where a messaging system moves messages that cannot be processed after a set number of attempts. It stops one bad message, often called a poison message, from blocking or endlessly retrying in the main queue. Engineers inspect the DLQ later, fix the cause and replay the messages.

How it works

The consumer tries a message and fails. The broker or client library redelivers it until it reaches a limit, such as maxReceiveCount in Amazon SQS or MaxDeliver in NATS JetStream. Then it moves the message to the DLQ, usually with the error and attempt count attached. For example, with a limit of 5, a message with malformed JSON fails five times and moves aside, while the other 10,000 messages that minute flow on.

Why it matters in production

Without a DLQ, a poison message either blocks an ordered partition or is dropped silently. With one, failures become visible and recoverable. Alert when DLQ depth rises above zero, and keep its retention long enough to replay, since an SQS queue keeps messages for at most 14 days.

See also

On the One2N blog

Further reading

Comic about a dead letter queue: a worker keeps failing on one broken message while everything behind it waits; the fix allows only 5 tries; after the 5th failure the message moves to a side queue, the dead letter queue, and the other messages keep flowing; Kai will find out why it failed and replay it, with an alert when the side queue fills.