-1

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:

    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()
    );

The exception thrown is

 java.lang.reflect.UndeclaredThrowableException

This is a different except than "Exception in thread "main" java.io.IOException: No broker could be found in the JMX."

Sein3i8
  • 133
  • 1
  • 1
  • 10
  • Possible duplicate of [Accessing Apache ActiveMQ via JMX throws Exception Broker Not Found 5.10](https://stackoverflow.com/questions/45640731/accessing-apache-activemq-via-jmx-throws-exception-broker-not-found-5-10) – Tim Bish Aug 11 '17 at 21:31

1 Answers1

0

Replace your object name with a stuff* wildcard

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

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

user1198289
  • 637
  • 1
  • 5
  • 14