This week, we’ll study a pattern known as Dead Letter Channel.
When do I use this pattern?
Dead Letter Channel is used for messages that were not delivered to the receivers. For example, if a message cannot be delivered because a receiver is down or the quota of calls is reached, then the message is moved to Dead Letter Channel. Note that, in CPI, implementation of Dead Letter Channel can only be used to tackle Node failure or Out of Memory issues.
Dead Letter Channel in CPI
In CPI, Dead Letter Channel can be used by changing the configuration on the JMS Sender Adapter.
Integration Flow – Fetch Orders
This flow starts immediately using Timer Start Event, sets the body using Content Modifier, and pushes the message in JMS Queue ‘Orders’ using JMS Receiver Adapter.
Configuration of JMS Receiver Adapter
Integration Flow – Send Orders
This flow fetches the Orders from ‘Orders’ queue using JMS Sender Adapter and sends an email with contents using Mail Receiver Adapter.
Configuration of JMS Sender Adapter
Please note that Dead-Letter Queue is checked and this will create a Queue that holds messages that have been failed to be delivered.
Configuration of Mail Receiver Adapter
We’ll run the first flow once to have the message in the queue. Then, we’ll run the second flow to consume the message.
If the number of orders placed is large enough, then there might be a node failure or out of memory error. In that case, the message is moved to the Dead Letter Queue. This message can be found in the Queue Monitor with status Blocked.
The messages can be moved back to the queue from Dead Letter Queue once the issue has been resolved by simply retrying them.
For more detailed information on Dead Letter Channel, check out Mandy Krimmel‘s blog on configuring Dead Letter Handling in JMS Adapter.
EIPinCPI Rating – 8/10
With the support of JMS, CPI supports Dead Letter Channel. However, Dead Letter Channel only deals with issues inside CPI and the developer will need to create their own Dead Letter Queue similar to Invalid Message Channel to handle the delivery issues. Therefore, in my opinion, this pattern gets 8 out of 10 EIPinCPI rating.
Dead Letter Channel is useful for storing messages that have failed delivery. Later, the messages could be moved to the original queue for retry. In CPI, only CPI’s internal issues like node failure or out of memory error are handled in Dead Letter Channel.
Hope this helps,
About the Author
More Content by Bhalchandra Wadekar