activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manav <vyakaranam_2...@yahoo.com>
Subject Re: [Spam: 5.0] Expired Message Listener
Date Thu, 22 Feb 2007 23:57:05 GMT

Could someone pease respond back to the posted question? 

We are holding off a release as we cannot get (do not know how to get)
message expiry to work in 4.1. This is critical to a big company using AMQ.

Any immediate help / suggestion is appreciated.

Manav



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#a9111016
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message