我正在使用一个新的ActiveMQ 5.10.0安装,其中我在一个名为“测试”的队列中有一条消息。我还替换了bin/tivemq中的ACTIVEMQ_SUNJMX行以启用JMX:
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,connector=clientConnectors,connectorName=openwire");
// ObjectName activeMQ = new ObjectName("org.apache.activemq:type=Broker,brokerName=TOM");
Set<ObjectName> brokers = conn.queryNames(activeMQ, null);
if (brokers.size( ) == 0) {
throw new IOException("No broker could be found in the JMX.");
}
System.out.println("brokers.size() = " + brokers.size());
for (int i = 0; i < brokers.size(); i++) {
System.out.println("brokers = " + brokers.toArray()[i]);
}
// ObjectName name = brokers.iterator().next();
// BrokerViewMBean mbean = MBeanServerInvocationHandler.newProxyInstance(conn, activeMQ, BrokerViewMBean.class, true);
ConnectionViewMBean mbean = MBeanServerInvocationHandler.newProxyInstance(conn, activeMQ, ConnectionViewMBean.class, true);
System.out.println(" mbean.getConsumers()\n = " + mbean.getConsumers()
);
抛出的异常是
java.lang.reflect.UndeclaredThrowableException
这与线程"main"中的"Exception"java.io不同。IOException:在JMX中找不到代理。"
用内容*通配符替换您的对象名称
"org. apache.active m q:type=Broker,Broker Name=TOM,连接器=客户端连接器,连接器名称=开放线路"
"org. apache.active m q:type=经纪人,经纪人名称=TOM,连接器=客户端连接器,连接器名称=开放线路*"