This doesn't work correctly in 4.x at the moment. Please could you raise a jira issue for it
cheers, Rob manav wrote: > > 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 = > dlq.getDeadLetterNameFromDestination((ActiveMQDestination)destination); > 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 { > MIBLogger.messageDead(txtMsg.getJMSCorrelationID(), > MIBConstants.DLQREASON_REQQ); > auditImpl.logSuccessEvent(AuditHelper.EVT_MSGDEAD, > txtMsg.getJMSCorrelationID(), MIBConstants.DLQREASON, > MIBConstants.DLQREASON_REQQ); > } catch (Exception ex) { > ex.printStackTrace(); > } > } > } > > Thanks a lot in advance.. > > Manav. > -- View this message in context: http://www.nabble.com/Expired-Message-Listener-tf3270915s2354.html#a9123822 Sent from the ActiveMQ - User mailing list archive at Nabble.com.