ActiveMQ消息特性:通知消息(AdvisoryMessage)

更新时间:2023-06-25 17:28:21 阅读: 评论:0

ActiveMQ消息特性:通知消息(AdvisoryMessage)
通知消息(Advisory Message)
简单的说就是实现了ActiveMQ的broker上各种操作的记录跟踪和通知。
使⽤这个功能,你可以实时的知道broker上
颜真卿书法作品1. 创建或销毁了连接,
2. 添加或删除了⽣存者或消费者,
3. 添加或删除了主题或队列,
4. 有消息发送和接收,
5. 什么时候有慢消费者,
6. 什么时候有快⽣产者
7. 什么时候什么消息被丢弃
8. 什么时候broker被添加到集群(主从或是⽹络连接)
这个机制是ActiveMQ对JMS协议的重要补充,也是基于JMS实现的ActiveMQ的可管理性的⼀部分。多个ActiveMQ的相互协调和互操作的基础设置。
使⽤⽰例与注意事项
使⽤很简单,完全的jms⽅式,⽰例如下
...
Destination advisoryDestination = ProducerAdvisoryTopic(destination)
MessageConsumer consumer = ateConsumer(advisoryDestination);
consumer.tMessageListener(this);
....
public void onMessage(Message msg){
if (msg instanceof ActiveMQMessage){
try {
ActiveMQMessage aMsg =  (ActiveMQMessage)msg;
ProducerInfo prod = (ProducerInfo) DataStructure();
} catch (JMSException e) {
<("Failed to process message: " + msg);
}
}
}
通过拿到的消息的数据结构,可以进⼀步的拿到相关操作信息。
⽽且Advisory消息都是先返回当前的所有存在数据,⽐如现在已经存在的所有连接或是队列信息,然后再实时通知你新创建和断开的连接,新添加或删除的队列等等。。。春雨诗歌
ActiveMQ.Advisory.Queue 数据结构为DestinationInfo,先拿到broker上现有的所有队列列表
如果再有add或remove队列的操作,拿到通知,operationType=0为add,为1则为remove
为topic时,⾃动过滤掉Advisory的topic。
ActiveMQ.Advisory.Producer.Queue 数据结构为ProducerInfo,其中包含Producer的参数信息
ActiveMQ.Advisory.Consumer.Queue 数据结构为ConsumerInfo,其中包含Consumer的参数信息
使⽤的时候,需要以此为前缀,监听需要的队列,⽐如kk.adt,则应该写
Topic topic = new ActiveMQTopic("ActiveMQ.Advisory.Consumer.Queue.kk.adt");
监听所有队列则
Topic topic = new ActiveMQTopic("ActiveMQ.Advisory.Consumer.Queue..>");
Producer或Consumer断开时,数据结构为RemoveInfo。
主题的监听类似。
持久订阅者上线时是ConsumerInfo,⾥⾯有clientId和consumerId,下线时的RemoveInfo⾥有consumerId,跟上线时对应。
ActiveMQ内置了⼀些⼯具类,根据你需要监听的队列名,⾃动拼Advisory的名称:
例如 ProducerAdvisoryTopic(new ActiveMQTopic("kk.adt"));
broker接收到或是投递消息的通知默认是关闭的。
需要在policy上设置相应的开关。 消息处理相关的Advisory的数据结构是消息本⾝。
客户端连接相关的通知消息都是默认开启的
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='consumerCount' - the number of Consumers ConsumerInfo ActiveMQ.Advisory.Consumer.Topic Consumer start & stop messages on a Topic String='consumerCount' - the number of Consumers ConsumerInfo
队列和消息的通知消息队列相关的是默认开启的,消息相关的都需要⼿⼯配置Pilocy选项开启
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='orignalMessageId' - the
expired id
Message true none
ActiveMQ.Advisory.Expired.Topic Expired messages on a Topic String='orignalMessageId' - the
expired id
Message true none
ActiveMQ.Advisory.NoConsumer.Queue No consumer is available to process messages being nt on a
Queue
null Message fal ndAdvisoryIfNoConsumers
ActiveMQ.Advisory.NoConsumer.Topic No consumer is available to process messages being nt on a
Topic
安装通
null Message fal ndAdvisoryIfNoConsumers
从5.2版本新加的消息处理与性能相关的,都需要⼿⼯启动
Advisory Topics Description properties
Data
Structure
default PolicyEntry property形容看的成语
ActiveMQ.Advisory.SlowConsumer.Queue Slow Queue Consumer String='consumerId' - the consumer id ConsumerInfo fal advisoryForSlowConsumers ActiveMQ.Advisory.SlowConsumer.Topic Slow Topic Consumer String='consumerId' - the consumer id ConsumerInfo fal advisoryForSlowConsumers ActiveMQ.Advisory.FastProducer.Queue Fast Queue producer String='producerId' - the producer id ProducerInfo fal advisdoryForFastProducers ActiveMQ.Advisory. FastProducer.Topic Fast Topic producer String='consumerId' - the producer id ProducerInfo fal advisdoryForFastProducers ActiveMQ.Advisory.MessageDiscarded.Queue Message discarded String='orignalMessageId' - the discarded id Message fal advisoryForDiscardi
ngMessages
ActiveMQ.Advisory.MessageDiscarded.Topic Message discarded String='orignalMessageId' - the discarded id Message fal advisoryForDiscardingMessages ActiveMQ.Advisory.MessageDelivered.Queue Message delivered to the broker String='orignalMessageId' - the delivered id Message fal advisoryForDelivery ActiveMQ.Advisory.MessageDelivered.Topic Message delivered to the broker String='orignalMessageId' - the delivered id Message fal advisoryForDelivery ActiveMQ.Advisory.MessageConsumed.Queue Message consumed by a client String='orignalMessageId' - the delivered id Message fal advisoryForConsumed ActiveMQ.Advisory.MessageConsumed.Topic Message consumed by a client String='orignalMessageId' - the delivered id Message fal advisoryForConsumed
ActiveMQ.Advisory.FULL    A Usage resource is at its limit String='usageName' - the name of Usage
车位出租协议
resource
null fal advisoryWhenFull
ActiveMQ.Advisory.MasterBroker A broker is now the master in a master/slave
configuration
null null true none
从5.4版本新加的DLQ的通知消息
Advisory Topics Description properties Data Structure default PolicyEntry property ActiveMQ.Advisory.MessageDLQd.Queue Message nt to DLQ String='orignalMessageId' - the delivered id Message Always on advisoryForConsumed ActiveMQ.Advisory.MessageDLQd.Topic Message nt to DLQ String='orignalMessageId' - the delivered id Message Always on advisoryForConsumed
从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, fal 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
打开通知消息开关的⽰例
此外,在broker上有个通知消息的总开关,设置fal以后,所有的Advisory都不可⽤: <broker advisorySupport="fal">...

本文发布于:2023-06-25 17:28:21,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1037807.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:消息   通知   队列   相关   连接   需要   默认
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图