1
votes

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.

2

2 Answers

4
votes

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

1
votes

Hassen is totally right regarding the possibility to set up a MDB consuming DLQ entries.

However the right place to set up a redelivery policy is on a queue or topic itself (see http://activemq.apache.org/redelivery-policy.html) and not using the dead letter queue. Indeed you have only one DLQ instance for the MOM which will contain messages from all the different queues / topic and setting up a failover mechanism there will imply to manage the different message structure