Search code examples
javaactivemq-classicmq

Java ActiveMQ - how to send expired messages to another queue


I have a requirement where messages on the queue have to expire if the client doesn't read them after 60 seconds. Instead of deleting the messages, I want to send them to another queue like an "expired message" queue or something. I have read a little bit about the Dead Letter Queue and the Back Out queue, but I'm not sure if those are doing what I need.

Here is my code for expiring after 60 seconds:

MessageProducer producer = session.createProducer(destination);

producer.setTimeToLive(60 * 1000);

Any help is appreciated. Thanks.


Solution

  • by default, AMQ will send expired messages to the DLQ

    see http://activemq.apache.org/message-redelivery-and-dlq-handling.html