Search in sources :

Example 1 with NetworkConnectorViewMBean

use of org.apache.activemq.broker.jmx.NetworkConnectorViewMBean in project activemq-artemis by apache.

the class JmxCreateNCTest method testBridgeRegistration.

@Test
public void testBridgeRegistration() throws Exception {
    BrokerService broker = new BrokerService();
    broker.setBrokerName(BROKER_NAME);
    // explicitly set this so no funny issues
    broker.setUseJmx(true);
    broker.start();
    broker.waitUntilStarted();
    // now create network connector over JMX
    ObjectName brokerObjectName = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + BROKER_NAME);
    BrokerViewMBean proxy = (BrokerViewMBean) broker.getManagementContext().newProxyInstance(brokerObjectName, BrokerViewMBean.class, true);
    assertNotNull("We could not retrieve the broker from JMX", proxy);
    // let's add the NC
    String connectoName = proxy.addNetworkConnector("static:(tcp://localhost:61617)");
    assertEquals("NC", connectoName);
    // Make sure we can retrieve the NC through JMX
    ObjectName networkConnectorObjectName = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + BROKER_NAME + ",connector=networkConnectors,networkConnectorName=" + connectoName);
    NetworkConnectorViewMBean nc = (NetworkConnectorViewMBean) broker.getManagementContext().newProxyInstance(networkConnectorObjectName, NetworkConnectorViewMBean.class, true);
    assertNotNull(nc);
    assertEquals("NC", nc.getName());
}
Also used : BrokerViewMBean(org.apache.activemq.broker.jmx.BrokerViewMBean) NetworkConnectorViewMBean(org.apache.activemq.broker.jmx.NetworkConnectorViewMBean) BrokerService(org.apache.activemq.broker.BrokerService) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

ObjectName (javax.management.ObjectName)1 BrokerService (org.apache.activemq.broker.BrokerService)1 BrokerViewMBean (org.apache.activemq.broker.jmx.BrokerViewMBean)1 NetworkConnectorViewMBean (org.apache.activemq.broker.jmx.NetworkConnectorViewMBean)1 Test (org.junit.Test)1