Advisory Support in ActiveMQ Classic 3

Site > Old Links > Previous Versions > Advisory Support in ActiveMQ Classic 3

For users of Apache ActiveMQ Classic 4.0 or later please see Advisory Message. In previous 3.x versions the following is supported:-

The destination string constants are available in ActiveMQDestination

ActiveMQDestination.CONSUMER_ADVISORY_PREFIX
ActiveMQDestination.PRODUCER_ADVISORY_PREFIX
ActiveMQDestination.CONNECTION_ADVISORY_PREFIX
ActiveMQDestination.TEMP_DESTINATION_ADVISORY_PREFIX

A subscription to each of the destination returns an ObjectMessage with a specific object: ConsumerInfo, ProducerInfo,ConnectionInfo, TempDestinationAdvisoryEvent.

For example:

... 
String advisoryName = ActiveMQDestination.PRODUCER_ADVISORY_PREFIX + destination.getPhysicalName(); 
Destination advisoryDestination = ActiveMQDestination.createDestination(destination.getDestinationType(), advisoryName); 
MessageConsumer consumer = session.createConsumer(advisoryDestination); 
consumer.setMessageListener(this); 
.... 

public void onMessage(Message msg) {
   if (msg instanceof ObjectMessage) {
      try {
         ProducerInfo info = (ProducerInfo)((ObjectMessage)msg).getObject();
      } catch (JMSException e) {
         log.error("Failed to process message: " + msg); 
      } 
   }
}

Apache, ActiveMQ, Apache ActiveMQ, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright © 2024, The Apache Software Foundation. Licensed under Apache License 2.0.