Accessing Apache ActiveMQ via JMX throws Exception

2019-09-14 21:24发布

I'm using a fresh ActiveMQ 5.10.0 installation, where I have a message in a queue called 'testing'. I also replaced the ACTIVEMQ_SUNJMX line in bin/activemq to enable JMX:

ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

JMXServiceURL url1 = new 
JMXServiceURL("service:jmx:rmi:///jndi/rmi://10.222.222.222:1099/jmxrmi");
    JMXConnector jmxc = JMXConnectorFactory.connect(url1);
    MBeanServerConnection conn = jmxc.getMBeanServerConnection( );
    ObjectName activeMQ = new 
 ObjectName("org.apache.activemq:type=Broker,BrokerName=TOM");

    System.out.println(newProxyInstance(conn, activeMQ, BrokerViewMBean.class, true).toString( ));
    Set<ObjectName> brokers = conn.queryNames(activeMQ, null);
                      if (brokers.size() == 0) {
                                    throw new IOException("No broker could be found in the JMX.");
                         }

The exception thrown is

Exception in thread "main" java.io.IOException: No broker could be found in 
the JMX.

Similar to Accessing Apache ActiveMQ via JMX throws Exception but did not help. Any ideas?

1条回答
淡お忘
2楼-- · 2019-09-14 21:57

You need to connect to activemq's jmx . In CLI type jconsole or go to your JDK bin path and run jconsole from command line.enter image description here You will see this interface. Connect to your jmx.enter image description here Go here exactly and look at your object. Copy exactly into your object name. Any! difference and you will not get your broker.

查看更多
登录 后发表回答