ActiveMQ对于某种队列或消息的接受

ActiveMQ 支持Advisory Messages,它允许你通过标准的JMS 消息来监控系统。目前的Advisory Messages支持:

  • consumers, producers and connections starting and stopping
  • temporary destinations being created and destroyed
  • messages expiring on topics and queues
  • brokers sending messages to destinations with no consumers.
  • connections starting and stopping

Advisory Messages可以被想象成某种的管理通道,通过它你可以得到关于JMS providerproducersconsumersdestinations的信息。Advisory topics都使用ActiveMQ.Advisory.这个前缀,以下是目前支持的topics

Client based advisories

Advisory Topics

Description

ActiveMQ.Advisory.Connection

Connection start & stop messages

ActiveMQ.Advisory.Producer.Queue

Producer start & stop messages on a Queue

ActiveMQ.Advisory.Producer.Topic

Producer start & stop messages on a Topic

ActiveMQ.Advisory.Consumer.Queue

Consumer start & stop messages on a Queue

ActiveMQ.Advisory.Consumer.Topic

Consumer start & stop messages on a Topic

在消费者启动/停止的Advisory Messages的消息头中有个consumerCount属性,他用来指明目前desination上活跃的consumer的数量。

Destination and Message based advisories

Advisory Topics

Description

ActiveMQ.Advisory.Queue

Queue create & destroy

ActiveMQ.Advisory.Topic

Topic create & destroy

ActiveMQ.Advisory.TempQueue

Temporary Queue create & destroy

ActiveMQ.Advisory.TempTopic

Temporary Topic create & destroy

ActiveMQ.Advisory.Expired.Queue

Expired messages on a Queue

ActiveMQ.Advisory.Expired.Topic

Expired messages on a Topic

ActiveMQ.Advisory.NoConsumer.Queue

No consumer is available to process messages being sent on a Queue

ActiveMQ.Advisory.NoConsumer.Topic

No consumer is available to process messages being sent on a Topic

以上的这些destnations都可以用来作为前缀,在其后面追加其它的重要信息,例如topicqueueclientID producderIDconsumerID等。这令你可以利用Wildcards Selectors 来过滤Advisory Messages(关于WildcardSelector会在稍后介绍)。

例如,如果你希望订阅FOO.BAR这个queueConsumerstart/stop的消息,那么可以订阅 ActiveMQ.Advisory.Consumer.Queue.FOO.BAR;如果希望订阅所有queue上的start/stop消息,那么可 以订阅ActiveMQ.Advisory.Consumer.Queue.>;如果希望订阅所有queue或者topic上的 start/stop消息,那么可以订阅ActiveMQ.Advisory.Consumer. >

 

举个例子:例如我们想监听所有以ActiveMQ.Advisory.Consumer.Topic.开头的TOPIC.那么我们在服务端发布发布的TOPIC就必须以ActiveMQ.Advisory.Consumer.Topic.XX的形式写,然后客户端就可以通过接受ActiveMQ.Advisory.Consumer.Topic.>的形式来接受所有这类似的TOPIC.

注意.如果我们要监听以ActiveMQ.Advisory.Consumer.Topic等形式的TOPIC我们的客户端就不能是持久话的。也就是persistent必须设置为false

你可能感兴趣的:(activemq,jms)