Accessing messages in Dead letter Queue of ActiveMQ and redeliver to webservice or socket after consumption

Chetan Sistla picture Chetan Sistla · Oct 10, 2016 · Viewed 7.7k times · Source

Iam writing an application in Java using ActiveMQ where iam using a producer and a asynchronous consumer mechanism where the messages sent by the producer are not consumed due to network failures.Hence these messages are sent to dead letter queue of ActiveMQ.

My question is how to access the messages in dead letter queue and perform retry on the same by consuming it in the consumer and send to a webservice or socket etc.Any code example would be great.

Answer

Hassen Bennour picture Hassen Bennour · Oct 10, 2016

DLQ is like any topic or queue and you can subscribe to it like any topic or queue and consume messages accumulated. Here is the list http://activemq.apache.org/advisory-message.html

The name of the DLQ to subscribe to it is ActiveMQ.DLQ if you not have an individualDeadLetterStrategy , you subscribe and do your business onMessage method . http://activemq.apache.org/message-redelivery-and-dlq-handling.html