Dead Letter Queue in Redhat Fuse and Apache Camel

Dead Letter Channel.

The Dead Letter Queue (DLQ) is an error handling functionality in Redhat Fuse, and Apache Camel specifically.  It is based on the Dead Letter Channel Enterprise Integration Pattern.

Dead Letter Channel Pattern

In this pattern the sender sends a message to the receiver through a queue. If for some reason the receiver cannot process the message, the original message will be forwarded to another queue called „Dead Letter Queue“. There it can be analysed by an operator or another automated process. The main objective of this pattern is to avoid loss of information. Furthermore, it also avoids that the original queue collapses because it fills up.

DLQ in Fuse.

Also, every time you create a queue in Fuse AMQ it will have per default “DLQ” as the Dead Letter Address configured:

DLQ in Fuse

Additionally, the DLQ address is a general queue provided by AMQ in Redhat Fuse and does not need to be configured or created.


Also, you can configure different queues according to your need. To achieve this, just edit the broker.xml configuration file and define a the required  addresses:

DLQ in Apache Camel.

But defining your own queue or using the default Dead Letter Address won’t be enough if you are processing the messages using Apache Camel. According to the official documentation, only the Dead Letter Channel error handler will redeliver the fault message to the DLQ:

Error Handling Apache Camel

So, in order to forward the message to a DLQ you will need to add the Dead Letter error handler in your Camel route like in this example:

If you notice in the example from above, the error handler defines a jms address to forward the message. This address will take precedence over the one defined in the broker.xml file. In other words, the JMS message will be forwarded to “deadtest” even if my queue has DLQ configured.

Custom Camel DLQ

In summary, the Dead Letter Channel error handler in Camel allows you to take advantage of the DLQ pattern implementation in Redhat Fuse. Furthermore, it also let you define the queue address in your code instead of a centralised xml file.


Enterprise Integration Patters:

Error Handler in Apache Camel: