Search code examples
javaactivemq-classicjmx

ActiveMQ: Get list of connections through JMX?


How do I get the list of the connections to the OpenWire connector of ActiveMQ? JConsole is able to list the connections, but I don't see which "view" I can use to get the list:

Example ObjectName of a connection: org.apache.activemq:BrokerName=localhost,Type=Connection,ConnectorName=openwire,Connection=toto

I tried "ConnectorViewMBean", but the operations on it don't allow me to list the connections:

ObjectName name = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Connection,ConnectorName=openwire"); 
mbsc.getMBeanInfo(name); 
ConnectorViewMBean view = JMX.newMBeanProxy(mbsc, name, ConnectorViewMBean.class);

Solution

  • The solution was the usage of an expression:

    ObjectName connectionNames = 
          new ObjectName("org.apache.activemq:BrokerName=localhost," + 
                         "Type=Connection,ConnectorName=openwire,Connection=*");
    
    Set<ObjectName> names = mbsc.queryNames(connectionNames, null); 
    for(ObjectName name : names) { 
       logger.error("Name: "+name.getCanonicalName()); 
    }