Showing posts from February, 2018

How to get consumer count using JMX API in ActiveMQ

first, get a connection to a JMX server (assumes localhost, port 9010, no auth)

First you need to start activemq with jmx service. Add below jvm parameters to java opts- -Djava.rmi.server.hostname=localhost

JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9010/jmxrmi");       JMXConnector jmxc = JMXConnectorFactory.connect(url);       MBeanServerConnection conn = jmxc.getMBeanServerConnection();       ObjectName activeMQ = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost");       BrokerViewMBean mbean = (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(conn,           activeMQ, BrokerViewMBean.class, true);       for (ObjectName name : mbean.getQueues()) {         QueueViewMBean qu…