In the most recent versions of ActiveMQ (5.1x.x), you can use the BrokerViewMBean to get a map of transport connectors:
Map<String, String[]> env = new HashMap<>();
String[] creds = {brokerUsername, brokerPassword};
env.put(JMXConnector.CREDENTIALS, creds);
final String managementURL = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
try (JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(managementURL, env)) {
ObjectName on = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost");
BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(connector.getMBeanServerConnection(), on, BrokerViewMBean.class, false);
Map<String, String> transportConnectors = broker.getTransportConnectors();
// broker.getTransportConnectorsByType("tcp"); // openwire
// broker.addConnector(String discoveryAddress);
// broker.removeConnector(String connectorName);
} catch (MalformedObjectNameException ex) {
// log error
} catch (IOException ex) {
// log error
} catch (Exception ex) {
// log error
}
Check also out ConnectorViewMBean.
However, while there are methods in BrokerViewMBean
to get transport connectors, as demonstrated in the above code, there aren't any to get a list of network (a.k.a. broker-to-broker) connectors.