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

Four-panel comic about Dead letter queue: One message with malformed JSON fails over and over and blocks the queue behind it; The consumer retries it up to a limit. After the last failure the broker moves it to a dead letter queue; With a limit of 5, the bad message moves aside after 5 tries and...