Enterprise Integration Patterns
Messaging Patterns
Messaging Patterns
Dead Letter ChannelDead Letter ChannelMessaging Patterns » Messaging Channels

An enterprise is using Messaging to integrate applications.

What will the messaging system do with a message it cannot deliver?

When a messaging system determines that it cannot or should not deliver a message, it may elect to move the message to a Dead Letter Channel.

The specific way a Dead Letter Channel works depends on the specific messaging system’s implementation, if it provides one at all. The channel may be called a “dead message queue” [Monson-Haefel, p.125] or dead letter queue (DLQ). [MQSeries], [Dickman, pp.28-29] Typically, each machine the messaging system is installed on has its own local Dead Letter Channel so that whatever machine a message dies on, it can be moved from one local queue to another without any networking uncertainties. This also records what machine the message died on. When the messaging system moves the message, it may also record the original channel the message was supposed to be delivered on.

... Read the entire pattern in the book Enterprise Integration Patterns

Example: Dead Letter Queue in Amazon SQSNEW

Many hosted messaging systems, including Amazon's Simple Queuing Service (SQS) include a Dead Letter Channel. Amazon's Dead Letter Queue behavior is closely related to the way SQS delivers messages. After a consumer fetches a message from a queue, the messages remains on the queue, but hidden from other consumers to avoid fetching and processing the same message multiple times. After processing a message, the consumer is responsible for explicitly deleting the message. If the consumer doesn't delete the message, for example because because it crashed while processing the message, the message becomes visible again after the message's Visibility Timeout expires. Each time this happens, the message's receive count is increased. When this count reaches a configured limit, the message is considered undeliverable and placed in a designated Dead Letter Queue. Other AWS services like Amazon EventBridge also feature a Dead Letter Channel.

Example: Kafka ConnectNEW

Kafka Connect, Confluent's tool for data streaming to and from Kafka includes a Dead Letter Channel for sink connectors. As per the documentation, the Dead Letter Channel is active when the connector is configured to tolerate errors (otherwise, it'd abort and not send messages to any queue). The name of the Dead Letter Channel can easily be configured:

errors.tolerance = all
errors.deadletterqueue.topic.name = <dead-letter-topic-name>

Related patterns:

Invalid Message Channel, Message Expiration, Selective Consumer, Messaging

Creative Commons Attribution License

You can reuse the following elements under the Creative Commons Attribution license: pattern icon, pattern name, problem and solution statements (in bold), and the sketch. Other portions are protected by copyright.

Enterprise Integration Patterns book cover

Enterprise Integration Patterns
The classic, as relevant as ever. Over 90,000 copies sold.

Software Architect Elevator book cover

The Software Architect Elevator
Learn how architects can play a critical role in IT transformation by applying their technical, communication, and organizational skills.

Cloud Strategy book cover

Cloud Strategy
Fill the large gap between high-level goals and product details by understanding decision trade-offs.