activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kalpana Jalawadi <>
Subject AdvisoryConsumer
Date Fri, 30 Apr 2010 06:57:08 GMT


I'm using AdvisoryConsumer in my MessageProducer to listen to the consumers
activities. On a consumer shutdown, I would want to perform some cleanup
job. Below is the code:

        Topic advisoryTopic = AdvisorySupport
        MessageConsumer advisoryConsumer =
        advisoryConsumer.setMessageListener(new MessageListener() {
            public void onMessage(Message message) {
                if (message instanceof ActiveMQMessage) {
                    ActiveMQMessage aMsg = (ActiveMQMessage) message;
                    DataStructure dataStructure = aMsg.getDataStructure();
                    if (dataStructure instanceof ConsumerInfo) {
                        System.out.println("Consumer started, ConsumerInfo
:" + message.toString());
                    } else if (dataStructure instanceof RemoveInfo) {
                        RemoveInfo removeInfo = (RemoveInfo) dataStructure;
                        DataStructure objectId = removeInfo.getObjectId();
                        System.out.println("Consumer stopped, ConsumerInfo
:" + message.toString());
                        // do some clean up

RemoveInfo command, exposes the consumerId (some magic string consisting of
connection id, session id and some long value), is there a way to find the
subscription name that is specified while creating the consumer using the
consumer id that is available to me? Or any other work around where I could
clearly identify who is the consumer who is dead?
Any help w.r.t this would be highly appreciated.

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

View raw message