【发布时间】:2023-04-04 15:23:02
【问题描述】:
我正在使用全新的 ActiveMQ 5.10.0 安装,其中我在名为“测试”的队列中有一条消息。我还替换了 bin/activemq 中的 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
这是一个不同于“线程“主”中的异常 java.io.IOException: No broker could be found in JMX。”
【问题讨论】: