Search code examples
javaactivemq-classicjmx

ActiveMQ get number of consumers listening to a topic from java


I would like to be able to get the number of consumers listening to a topic from java for an embedded ActiveMQ (5.4.2) broker in the same JVM. Is JMX really the only option here? JMX seems like a bad option since it may be optionally disabled. This post shows how to use JMX to get a list of connections: ActiveMQ: Get list of connections through JMX?

I would prefer a non-JMX based solution though due to it perhaps being disabled. I guess JMX would be ok if it was still usable from java when disabled. I am just familiar with enabling/disabling it for use with jconsole.

Am I missing something in the API?


Solution

  • you can use Advisory Messages to get the number of consumers of queues/topics (amongst other things) without using JMX (see ActiveMQ.Advisory.Consumer.Topic, etc)...