activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manav <>
Subject Expired Message Listener
Date Thu, 22 Feb 2007 04:22:29 GMT

We recently migrated our application from ActiveMQ3.2.1 to ActiveMQ 4.1.0.

We were using a listener for Expired messages (after timetolive) when we
used ActiveMQ 3.2.1 using DeadLetterPolicy class.

When we switched to ActiveMQ 4.1, we noticed that the DeadLetterPolicy class
has been changed in 4.1 and thus started to look around on how to listen to
expired messages.

All we want to do after listening to the messages is to log a message in out
application logs and make an audit entry (application specific). 

In ActiveMQ 3.2.1, we used the below code that uses the
org.activemq.deadletter.Destination concept to receive the expired messages.
This code worked like a charm in 3.2.1. Now we would like to achieve the
same functionality with AMQ4.1. Could someone please help us out with
equivalent code for 4.1?

//Code used with ActiveMQ3.2.1 for listening to expired messages..
import org.activemq.service.DeadLetterPolicy;

String dlqName = "org.activemq.deadletter.InquiryDestination";
Queue dlqDestination = session.createQueue(dlqName);

consumer = session.createReceiver(dlqDestination);
consumer.setMessageListener(new InquiryMessageListner());
DeadLetterPolicy dlq = new DeadLetterPolicy();
connection = connectionFactory.createQueueConnection();
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue destination = session.createQueue("InquiryDestination");
String dlqName =
Queue dlqDestination = session.createQueue(dlqName);

class InquiryMessageListner implements MessageListener {  
	private static AuditHelper auditImpl = new AuditHelper();
   	public void onMessage(Message message) {
		TextMessage txtMsg = (TextMessage) message;
		try {
txtMsg.getJMSCorrelationID(), MIBConstants.DLQREASON,
		} catch (Exception ex) {

Thanks a lot in advance..

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message