(Conversion) activemq message feature: Advisory message (notification message)

Source: Internet
Author: User

Simply put, it implements tracking and notification of various operations on the activemq broker.

 

With this function, you can know the broker in real time.

 

  1. Creates or destroys a connection,
  2. Added or deleted survivors or consumers,
  3. Added or deleted topics or queues,
  4. Messages are sent and received,
  5. When are there slow consumers,
  6. When will there be a producer?
  7. When And when messages are discarded
  8. When is the broker added to the cluster (Master/Slave or network connection)

 

This mechanism is an important supplement of activemq to the JMS protocol, and is also part of the manageability of activemq implemented based on JMS. Basic settings for coordination and interoperability among multiple activemq instances.

 

Examples and precautions


Simple to use, complete JMS method, example:

 

 

...    Destination advisoryDestination = AdvisorySupport.getProducerAdvisoryTopic(destination)    MessageConsumer consumer = session.createConsumer(advisoryDestination);    consumer.setMessageListener(this);....public void onMessage(Message msg){    if (msg instanceof ActiveMQMessage){        try {             ActiveMQMessage aMsg =  (ActiveMQMessage)msg;             ProducerInfo prod = (ProducerInfo) aMsg.getDataStructure();        } catch (JMSException e) {            log.error("Failed to process message: " + msg);        }    }}

The data structure of the received message further obtains the relevant operation information.

 

In addition, the advisory message first returns all existing data, such as all existing connections or queue information, and then notifies you of new and disconnected connections in real time, newly added or deleted queues...

The data structure of activemq. Advisory. queue is destinationinfo. The list of all existing queues on the broker is obtained first.
If there is another add or remove queue operation, get the notification, operationtype = 0 is add, and 1 is remove
When it is a topic, the advisory topic is automatically filtered out.

The activemq. Advisory. Producer. Queue data structure is producerinfo, which contains the producer parameter information.
Activemq. Advisory. Consumer. Queue data structure is consumerinfo, which contains the consumer parameter information
You need to use this prefix to listen to the required queue, such as KK. ADT, you should write
Topic topic = new activemqtopic ("activemq. Advisory. Consumer. queue. KK. ADT ");
Listen to all queues
Topic topic = new activemqtopic ("activemq. Advisory. Consumer. Queue...> ");
When the producer or consumer is disconnected, the data structure is removeinfo.
The topic listening is similar.

The persistent subscriber goes online with consumerinfo, which contains the clientid and consumerid. The removeinfo contains the consumerid, which corresponds to the consumerid when going online.

Activemq has some built-in tools. Based on the queue name you need to listen to, the advisory name is automatically spelled out:
For example, advisorysupport. getproduceradvisorytopic (New activemqtopic ("KK. ADT "));

Notifications of messages received or delivered by the broker are disabled by default.
You need to set the corresponding switch on the policy. The data structure of advisory related to message processing is the message itself.

Notifications related to client connection are enabled by default.
Advisory topics Description Properties Data Structure
Activemq. Advisory. Connection Connection start & stop messages
Activemq. Advisory. Producer. Queue Producer start & stop messages on a queue String = 'producercount'-the number of producers Producerinfo
Activemq. Advisory. Producer. Topic Producer start & stop messages on a topic String = 'producercount'-the number of producers Producerinfo
Activemq. Advisory. Consumer. Queue Consumer start & stop messages on a queue String = 'sumercount'-the number of consumers Consumerinfo
Activemq. Advisory. Consumer. Topic Consumer start & stop messages on a topic String = 'sumercount'-the number of consumers Consumerinfo

 

The notification message queue is enabled by default. You must manually configure the pilocy option to enable message-related services.
Advisory topics Description Properties Data Structure Default Policyentry Property
Activemq. Advisory. Queue Queue create & destroy Null Null True None
Activemq. Advisory. Topic Topic Create & destroy Null Null True None
Activemq. Advisory. tempqueue Temporary queue create & destroy Null Null True None
Activemq. Advisory. temptopic Temporary topic Create & destroy Null Null True None
Activemq. Advisory. Expired. Queue Expired messages on a queue String = 'nalnalmessageid'-the expired ID Message True None
Activemq. Advisory. Expired. Topic Expired messages on a topic String = 'nalnalmessageid'-the expired ID Message True None
Activemq. Advisory. noconsumer. Queue No consumer is available to process messages being sent on a queue Null Message False Sendadvisoryifnoconsumers
Activemq. Advisory. noconsumer. Topic No consumer is available to process messages being sent on a topic Null Message False Sendadvisoryifnoconsumers
Message Processing and performance related to the new version 5.2 must be manually started.
Advisory topics Description Properties Data Structure Default Policyentry Property
Activemq. Advisory. slowconsumer. Queue Slow queue consumer String = 'consumer id'-the consumer ID Consumerinfo False Advisoryforslowconsumers
Activemq. Advisory. slowconsumer. Topic Slow topic consumer String = 'consumer id'-the consumer ID Consumerinfo False Advisoryforslowconsumers
Activemq. Advisory. fastproducer. Queue Fast queue producer String = 'producerid'-the producer ID Producerinfo False Advisdoryforfastproducers
Activemq. Advisory. fastproducer. Topic Fast topic producer String = 'consumerid'-the producer ID Producerinfo False Advisdoryforfastproducers
Activemq. Advisory. messagediscarded. Queue Message discarded String = 'nalnalmessageid'-the discarded ID Message False Advisoryfordiscardingmessages
Activemq. Advisory. messagediscarded. Topic Message discarded String = 'nalnalmessageid'-the discarded ID Message False Advisoryfordiscardingmessages
Activemq. Advisory. messagedelivered. Queue Message delivered to the broker String = 'nalnalmessageid'-the delivered ID Message False Advisoryfordelivery
Activemq. Advisory. messagedelivered. Topic Message delivered to the broker String = 'nalnalmessageid'-the delivered ID Message False Advisoryfordelivery
Activemq. Advisory. messageconsumed. Queue Message consumed by a client String = 'nalnalmessageid'-the delivered ID Message False Advisoryforconsumed
Activemq. Advisory. messageconsumed. Topic Message consumed by a client String = 'nalnalmessageid'-the delivered ID Message False Advisoryforconsumed
Activemq. Advisory. Full A usage resource is at its limit String = 'usagename'-the name of usage Resource Null False Advisorywhenfull
Activemq. Advisory. masterbroker A broker is now the master in a Master/Slave Configuration Null Null True None
Notifications for the newly added dlq from version 5.4
Advisory topics Description Properties Data Structure Default Policyentry Property
Activemq. Advisory. messagedlqd. Queue Message sent to dlq String = 'nalnalmessageid'-the delivered ID Message Always on Advisoryforconsumed
Activemq. Advisory. messagedlqd. Topic Message sent to dlq String = 'nalnalmessageid'-the delivered ID Message Always on Advisoryforconsumed
Notification Message for the newly added network connection cluster from Version 5.5
Advisory topics Description Properties Data Structure Default
Activemq. Advisory. networkbridge Network Bridge being stopped or started Boolean = "started"-true if Bridge is started, false if it is stopped
Boolean = "createdbyduplex"-true if the bridge is created by remote network Connector
Brokerinfo-provides data of the remote Broker Always on
Example of enabling the notification message switch
<destinationPolicy>   <policyMap><policyEntries>       <policyEntry topic=">" advisoryForConsumed="true" />   </policyEntries></policyMap></destinationPolicy>

 

In addition, there is a general switch for notification messages on the broker. After setting false, all advisory will be unavailable:

 

<Broker advisorysupport = "false">...
From: http://blog.csdn.net/kimmking/article/details/8443679

 

(Conversion) activemq message feature: Advisory message (notification message)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.