2017-08-11 57 views
-1

我正在使用新鮮的ActiveMQ 5.10.0安裝,其中有一個名爲'testing'的隊列中有一條消息。我也換成了ACTIVEMQ_SUNJMX線斌/ ActiveMQ的啓用JMX:通過JMX訪問Apache ActiveMQ拋出ConnectionMBean 5.10

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’java.io.IOException的不同:沒有經紀人可以在 JMX中找到。「

+0

[通過JMX訪問Apache ActiveMQ拋出異常代理未找到5.10](https://stackoverflow.com/questions/45640731/)訪問的Apache-的ActiveMQ-通JMX拋出的異常經紀人未找到-5-10) –

回答

0

有東西通配符*

更換你的對象名稱 「org.apache.activemq:類型=經紀人,brokerName = TOM,連接器= clientConnectors,連接器名稱= openwire」

「org.apache.activemq :type = Broker,brokerName = TOM,connector = clientConnectors,connectorName = openwire *「