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