-
1. Re: How to programmatically get message count of a Topic on messaging-activemq
jbertram Aug 14, 2017 11:15 AM (in response to isurumd)Management beans are available for most Wildfly components. These MBeans typically mirror what's available via the Wildfly management CLI. For example, if you had a topic named "myTopic" it would have an MBean at "jboss.as:subsystem=messaging-activemq,server=default,jms-topic=myTopic".
-
2. Re: How to programmatically get message count of a Topic on messaging-activemq
isurumd Aug 15, 2017 3:31 AM (in response to isurumd)Thanks jbertram
i were able to get message count as follow.
had to include jboss-client.jar for class path
<code>
String host = "localhost";
int port = 9990;
String urlString =
System.getProperty("jmx.service.url","service:jmx:remote+http://" + host + ":" + port);
JMXServiceURL serviceURL = new JMXServiceURL(urlString);
JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null);
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
ObjectName activeMQ = new ObjectName("jboss.as:subsystem=messaging-activemq,server=default,jms-queue=ERROR");
System.out.println(connection.getAttribute(activeMQ, "message-count"));
jmxConnector.close();
</code>