use of org.apache.activemq.broker.jmx.BrokerViewMBean in project activemq-artemis by apache.
the class ManagementContextXBeanConfigTest method assertAuthentication.
public void assertAuthentication(JMXConnector connector) throws Exception {
connector.connect();
MBeanServerConnection connection = connector.getMBeanServerConnection();
ObjectName name = new ObjectName("test.domain:type=Broker,brokerName=localhost");
BrokerViewMBean mbean = MBeanServerInvocationHandler.newProxyInstance(connection, name, BrokerViewMBean.class, true);
LOG.info("Broker " + mbean.getBrokerId() + " - " + mbean.getBrokerName());
}
use of org.apache.activemq.broker.jmx.BrokerViewMBean in project activemq-artemis by apache.
the class AdvisoryJmxTest method testCreateDeleteDestinations.
public void testCreateDeleteDestinations() throws Exception {
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
JMXConnector connector = JMXConnectorFactory.connect(url, null);
connector.connect();
MBeanServerConnection connection = connector.getMBeanServerConnection();
ObjectName name = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost");
BrokerViewMBean brokerMbean = MBeanServerInvocationHandler.newProxyInstance(connection, name, BrokerViewMBean.class, true);
Connection conn = createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = sess.createConsumer(sess.createTopic("ActiveMQ.Advisory.Queue"));
conn.start();
Destination dest = sess.createQueue("test");
brokerMbean.addQueue("test");
ActiveMQMessage msg = (ActiveMQMessage) consumer.receive(1000);
assertNotNull(msg);
assertTrue(msg.getDataStructure() instanceof DestinationInfo);
assertEquals(((DestinationInfo) msg.getDataStructure()).getDestination(), dest);
assertEquals(((DestinationInfo) msg.getDataStructure()).getOperationType(), 0);
brokerMbean.removeQueue("test");
msg = (ActiveMQMessage) consumer.receive(1000);
assertNotNull(msg);
assertTrue(msg.getDataStructure() instanceof DestinationInfo);
assertEquals(((DestinationInfo) msg.getDataStructure()).getDestination(), dest);
assertEquals(((DestinationInfo) msg.getDataStructure()).getOperationType(), 1);
brokerMbean.addQueue("test");
msg = (ActiveMQMessage) consumer.receive(1000);
assertNotNull(msg);
assertTrue(msg.getDataStructure() instanceof DestinationInfo);
assertEquals(((DestinationInfo) msg.getDataStructure()).getDestination(), dest);
assertEquals(((DestinationInfo) msg.getDataStructure()).getOperationType(), 0);
assertEquals(((DestinationInfo) msg.getDataStructure()).getOperationType(), 0);
}
use of org.apache.activemq.broker.jmx.BrokerViewMBean in project activemq-artemis by apache.
the class MQTTNetworkOfBrokersFailoverTest method assertOneDurableSubOn.
@SuppressWarnings("unused")
private void assertOneDurableSubOn(BrokerService broker, String subName) throws Exception {
BrokerViewMBean brokerView = broker.getAdminView();
ObjectName[] activeDurableSubs = brokerView.getDurableTopicSubscribers();
ObjectName[] inactiveDurableSubs = brokerView.getInactiveDurableTopicSubscribers();
ObjectName[] allDurables = (ObjectName[]) ArrayUtils.addAll(activeDurableSubs, inactiveDurableSubs);
assertEquals(1, allDurables.length);
// at this point our assertions should prove that we have only on durable sub
DurableSubscriptionViewMBean durableSubView = (DurableSubscriptionViewMBean) broker.getManagementContext().newProxyInstance(allDurables[0], DurableSubscriptionViewMBean.class, true);
assertEquals(subName, durableSubView.getClientId());
}
use of org.apache.activemq.broker.jmx.BrokerViewMBean in project activemq-artemis by apache.
the class MQTTNetworkOfBrokersFailoverTest method assertQueueExistsOn.
private void assertQueueExistsOn(BrokerService broker, String queueName) throws Exception {
BrokerViewMBean brokerView = broker.getAdminView();
ObjectName[] queueNames = brokerView.getQueues();
assertEquals(1, queueNames.length);
assertTrue(queueNames[0].toString().contains(queueName));
}
use of org.apache.activemq.broker.jmx.BrokerViewMBean 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());
}
Aggregations