protected void removeAllMessages(final String queueName, final int index) throws Exception { ManagementService managementService = server0.getManagementService(); if (index == 1) { managementService = server1.getManagementService(); } JMSQueueControl queueControl = (JMSQueueControl) managementService.getResource(ResourceNames.JMS_QUEUE + queueName); queueControl.removeMessages(null); }
protected void checkNoSubscriptions(final Topic topic, final int index) throws Exception { ManagementService managementService = server0.getManagementService(); if (index == 1) { managementService = server1.getManagementService(); } TopicControl topicControl = (TopicControl) managementService.getResource(ResourceNames.JMS_TOPIC + topic.getTopicName()); Assert.assertEquals(0, topicControl.getSubscriptionCount()); }
public void testNotifications() throws Exception { SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener(); BridgeControl bridgeControl = createBridgeControl(bridgeConfig.getName(), mbeanServer); server_0.getManagementService().addNotificationListener(notifListener); Assert.assertEquals(0, notifListener.getNotifications().size()); bridgeControl.stop(); Assert.assertEquals(1, notifListener.getNotifications().size()); Notification notif = notifListener.getNotifications().get(0); Assert.assertEquals(NotificationType.BRIDGE_STOPPED, notif.getType()); Assert.assertEquals( bridgeControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()); bridgeControl.start(); Assert.assertEquals(2, notifListener.getNotifications().size()); notif = notifListener.getNotifications().get(1); Assert.assertEquals(NotificationType.BRIDGE_STARTED, notif.getType()); Assert.assertEquals( bridgeControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()); }
public boolean checkEmpty(final Queue queue, final int index) throws Exception { ManagementService managementService = server0.getManagementService(); if (index == 1) { managementService = server1.getManagementService(); } JMSQueueControl queueControl = (JMSQueueControl) managementService.getResource(ResourceNames.JMS_QUEUE + queue.getQueueName()); Long messageCount = queueControl.getMessageCount(); if (messageCount > 0) { queueControl.removeMessages(null); } return true; }
private AddressControl getAddressControl( final OperationContext context, final ModelNode operation) { final String addressName = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue(); final ServiceName hqServiceName = MessagingServices.getHornetQServiceName( PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR))); ServiceController<?> hqService = context.getServiceRegistry(false).getService(hqServiceName); HornetQServer hqServer = HornetQServer.class.cast(hqService.getValue()); return AddressControl.class.cast( hqServer.getManagementService().getResource(ResourceNames.CORE_ADDRESS + addressName)); }