简体   繁体   中英

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

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM