Services

Resources

Company

/

Dead letter queue

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

Queue diagram of a dead letter queue: messages in the main queue flow to a consumer, 10,000 a minute. One message keeps failing, retries 5 times, then moves to the dead letter queue, shown as a red bad JSON message with its error and attempt count attached. Notes: alert when depth is above 0, and SQS keeps messages 14 days at most. A dashed green arrow replays it to the main queue after the fix.

Putting this into practice?

Talk to One2N about our backend engineering services

Talk to One2N about our backend engineering services