Howto configure a custom Dead Letter Queue (DLQ) in WildFly

The Dead Letter Queue Address (DLQ) is a collector for messages which failed to be delivered over a number of attemps.

In WildFly, A dead letter address is defined in the address-setting element of the messaging-activemq subsystem configuration. To read the generic dead letter queue configuration for all destinations (“#”), use the following management CLI command as an example.

/subsystem=messaging-activemq/server=default/address-setting=#:read-attribute(name=dead-letter-address)
{
    "outcome" => "success",
    "result" => "jms.queue.DLQ"
}

If a dead-letter-address is not specified, messages are removed after trying to deliver max-delivery-attempts times. By default, messages delivery is attempted 10 times. Setting max-delivery-attempts to -1 allows infinite redelivery attempts.

If you want to define a specific DLQ for a destination, you can set is as follows:

/subsystem=messaging-activemq/server=default/address-setting=jms.queue.TestQueue:add(dead-letter-address=jms.queue.MyDLQ,max-delivery-attempts=3)

In the above example, we have set a custom DLQ (“jms.queue.MyDLQ”) for the address “jms.queue.TestQueue” where messages will be delivered after 3 failed attempts.

Please note that you must configure the jms.queue.MyDLQ before hand:

jms-queue --queue-address=MyDLQ --entries=java:/jms/MyDLQ

Recommended Articles

Create a Simple JMS Queue Producer and Consumer Using JBoss AS 5

Learn how to create a simple JMS Queue Producer and Consumer using JBoss AS 5. Includes Clustered JMS Queue configuration.

Understanding Message Redelivery in JBoss WildFly

Configure message redelivery on JBoss WildFly to ensure reliable message delivery. Learn about PERSISTENT and NON_PERSISTENT modes, max-delivery-attempts, and more.

Create a Remote JMS Client for WildFly 31: A Step-by-Step Guide

Learn how to create a remote JMS connection to a Queue deployed on WildFly application server. Get the latest guide and start coding now!

Developing a Native JMS Browser for WildFly and JBoss AS 7 using Java

Learn how to create a native interface to browse JMS queue messages in WildFly and JBoss AS 7, using Java and the javax.jms API.