@Override public void onNotification(org.apache.activemq.artemis.core.server.management.Notification notification) { if (!(notification.getType() instanceof CoreNotificationType)) return; CoreNotificationType type = (CoreNotificationType) notification.getType(); TypedProperties prop = notification.getProperties(); this.broadcaster.sendNotification(new Notification(type.toString(), this, notifSeq.incrementAndGet(), notification.toString())); }
@Override public MBeanNotificationInfo[] getNotificationInfo() { CoreNotificationType[] values = CoreNotificationType.values(); String[] names = new String[values.length]; for (int i = 0; i < values.length; i++) { names[i] = values[i].toString(); } return new MBeanNotificationInfo[]{new MBeanNotificationInfo(names, this.getClass().getName(), "Notifications emitted by a Core Server")}; }
CoreNotificationType ntype = CoreNotificationType.valueOf(type.toString());
@Test public void testCreateQueueNotification() throws Exception { JMSUtil.JMXListener listener = new JMSUtil.JMXListener(); this.mbeanServer.addNotificationListener(ObjectNameBuilder.DEFAULT.getActiveMQServerObjectName(), listener, null, null); SimpleString testQueueName = new SimpleString("newQueue"); String testQueueName2 = "newQueue2"; this.server.createQueue(testQueueName, RoutingType.MULTICAST, testQueueName, null, durable, false); Notification notif = listener.getNotification(); System.out.println("got notif: " + notif); assertEquals(CoreNotificationType.BINDING_ADDED.toString(), notif.getType()); this.server.destroyQueue(testQueueName); notif = listener.getNotification(); System.out.println("got notif: " + notif); assertEquals(CoreNotificationType.BINDING_REMOVED.toString(), notif.getType()); ActiveMQServerControl control = ManagementControlHelper.createActiveMQServerControl(mbeanServer); control.createQueue(testQueueName2, testQueueName2, RoutingType.MULTICAST.toString()); notif = listener.getNotification(); System.out.println("got notif: " + notif); assertEquals(CoreNotificationType.BINDING_ADDED.toString(), notif.getType()); control.destroyQueue(testQueueName2); notif = listener.getNotification(); System.out.println("got notif: " + notif); assertEquals(CoreNotificationType.BINDING_REMOVED.toString(), notif.getType()); }
@Test public void testSECURITY_AUTHENTICATION_VIOLATION() throws Exception { SSLSecurityNotificationTest.flush(notifConsumer); TransportConfiguration tc = new TransportConfiguration(NETTY_CONNECTOR_FACTORY); tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true); tc.getParams().put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, "client-side-truststore.jks"); tc.getParams().put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, "secureexample"); tc.getParams().put(TransportConstants.KEYSTORE_PATH_PROP_NAME, "bad-client-side-keystore.jks"); tc.getParams().put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, "secureexample"); ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc)); ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator)); try { sf.createSession(); Assert.fail("authentication must fail and a notification of security violation must be sent"); } catch (Exception e) { } ClientMessage[] notifications = SSLSecurityNotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(SECURITY_AUTHENTICATION_VIOLATION.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals(null, notifications[0].getObjectProperty(ManagementHelper.HDR_USER)); Assert.assertEquals("CN=Bad Client, OU=Artemis, O=ActiveMQ, L=AMQ, ST=AMQ, C=AMQ", notifications[0].getObjectProperty(ManagementHelper.HDR_CERT_SUBJECT_DN).toString()); Assert.assertTrue(notifications[0].getObjectProperty(ManagementHelper.HDR_REMOTE_ADDRESS).toString().startsWith("/127.0.0.1")); }
@Test public void testAddressAdded() throws Exception { SimpleString address = RandomUtil.randomSimpleString(); NotificationTest.flush(notifConsumer); session.createAddress(address, RoutingType.ANYCAST, true); ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(ADDRESS_ADDED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals(RoutingType.ANYCAST.getType(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_TYPE)); Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); }
@Test public void testBINDING_ADDED() throws Exception { SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); boolean durable = RandomUtil.randomBoolean(); NotificationTest.flush(notifConsumer); session.createQueue(address, queue, durable); //the first message received will be for the address creation ClientMessage[] notifications = NotificationTest.consumeMessages(2, notifConsumer); Assert.assertEquals(BINDING_ADDED.toString(), notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals(queue.toString(), notifications[1].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME).toString()); Assert.assertEquals(address.toString(), notifications[1].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); session.deleteQueue(queue); }
@Test public void testBINDING_REMOVED() throws Exception { SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); boolean durable = RandomUtil.randomBoolean(); session.createQueue(address, queue, durable); NotificationTest.flush(notifConsumer); session.deleteQueue(queue); //There will be 2 notifications, first is for binding removal, second is for address removal ClientMessage[] notifications = NotificationTest.consumeMessages(2, notifConsumer); Assert.assertEquals(BINDING_REMOVED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals(queue.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME).toString()); Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); }
@Test public void testSECURITY_AUTHENTICATION_VIOLATION() throws Exception { String unknownUser = RandomUtil.randomString(); SecurityNotificationTest.flush(notifConsumer); ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); try { sf.createSession(unknownUser, RandomUtil.randomString(), false, true, true, false, 1); Assert.fail("authentication must fail and a notification of security violation must be sent"); } catch (Exception e) { } ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(SECURITY_AUTHENTICATION_VIOLATION.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals(unknownUser, notifications[0].getObjectProperty(ManagementHelper.HDR_USER).toString()); Assert.assertEquals("unavailable", notifications[0].getObjectProperty(ManagementHelper.HDR_CERT_SUBJECT_DN).toString()); Assert.assertEquals("invm:0", notifications[0].getObjectProperty(ManagementHelper.HDR_REMOTE_ADDRESS).toString()); }
@Test public void testAddressRemoved() throws Exception { SimpleString address = RandomUtil.randomSimpleString(); session.createAddress(address, RoutingType.ANYCAST, true); NotificationTest.flush(notifConsumer); server.getPostOffice().removeAddressInfo(address); ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(ADDRESS_REMOVED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals(RoutingType.ANYCAST.getType(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_TYPE)); Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); }
@Test public void testCONSUMER_CREATED() throws Exception { SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); Role role = new Role("notif", true, true, true, true, false, true, true, true, true, true); Set<Role> roles = new HashSet<>(); roles.add(role); server.getSecurityRepository().addMatch("#", roles); TransportConfiguration tc = new TransportConfiguration(NETTY_CONNECTOR_FACTORY); tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true); tc.getParams().put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, "client-side-truststore.jks"); tc.getParams().put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, "secureexample"); tc.getParams().put(TransportConstants.KEYSTORE_PATH_PROP_NAME, "client-side-keystore.jks"); tc.getParams().put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, "secureexample"); ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc)); ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator)); ClientSession guestSession = sf.createSession("guest", "guest", false, true, true, false, 1); guestSession.createQueue(address, RoutingType.ANYCAST, queue, true); SSLSecurityNotificationTest.flush(notifConsumer); guestSession.createConsumer(queue); ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(CONSUMER_CREATED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals("guest", notifications[0].getObjectProperty(ManagementHelper.HDR_USER).toString()); Assert.assertEquals("first", notifications[0].getObjectProperty(ManagementHelper.HDR_VALIDATED_USER).toString()); Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); Assert.assertEquals("CN=ActiveMQ Artemis Client, OU=Artemis, O=ActiveMQ, L=AMQ, ST=AMQ, C=AMQ", notifications[0].getObjectProperty(ManagementHelper.HDR_CERT_SUBJECT_DN).toString()); guestSession.close(); }
@Test public void testBINDING_ADDEDWithMatchingFilter() throws Exception { SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); boolean durable = RandomUtil.randomBoolean(); System.out.println(queue); notifConsumer.close(); notifConsumer = session.createConsumer(notifQueue.toString(), ManagementHelper.HDR_ROUTING_NAME + "= '" + queue + "'"); NotificationTest.flush(notifConsumer); session.createQueue(address, queue, durable); ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(BINDING_ADDED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals(queue.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME).toString()); Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); session.deleteQueue(queue); }
@Override public void onMessage(ClientMessage message) { assertEquals(CoreNotificationType.CONSUMER_SLOW.toString(), message.getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); assertEquals(QUEUE.toString(), message.getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); assertEquals(Integer.valueOf(1), message.getIntProperty(ManagementHelper.HDR_CONSUMER_COUNT)); if (isNetty) { assertTrue(message.getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS).toString().startsWith("/127.0.0.1")); } else { assertEquals(SimpleString.toSimpleString("invm:0"), message.getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS)); } assertNotNull(message.getSimpleStringProperty(ManagementHelper.HDR_CONNECTION_NAME)); assertNotNull(message.getSimpleStringProperty(ManagementHelper.HDR_CONSUMER_NAME)); assertNotNull(message.getSimpleStringProperty(ManagementHelper.HDR_SESSION_NAME)); try { message.acknowledge(); } catch (ActiveMQException e) { e.printStackTrace(); } notifLatch.countDown(); } });
@Test public void testConnectionCreatedAndDestroyed() throws Exception { NotificationTest.flush(notifConsumer); ClientSessionFactory sf = createSessionFactory(locator); ClientSession mySession = sf.createSession("myUser", "myPassword", false, true, true, locator.isPreAcknowledge(), locator.getAckBatchSize()); mySession.start(); ClientMessage[] notifications = NotificationTest.consumeMessages(2, notifConsumer); Assert.assertEquals(CONNECTION_CREATED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertNotNull(notifications[0].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME)); final String connectionId = notifications[0].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME).toString(); Assert.assertEquals(SESSION_CREATED.toString(), notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertNotNull(notifications[1].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME)); Assert.assertNotNull(notifications[1].getObjectProperty(ManagementHelper.HDR_SESSION_NAME)); Assert.assertEquals(SimpleString.toSimpleString("myUser"), notifications[1].getObjectProperty(ManagementHelper.HDR_USER)); NotificationTest.flush(notifConsumer); mySession.close(); sf.close(); notifications = NotificationTest.consumeMessages(2, notifConsumer); Assert.assertEquals(SESSION_CLOSED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertNotNull(notifications[0].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME)); Assert.assertNotNull(notifications[0].getObjectProperty(ManagementHelper.HDR_SESSION_NAME)); Assert.assertEquals(SimpleString.toSimpleString("myUser"), notifications[0].getObjectProperty(ManagementHelper.HDR_USER)); Assert.assertEquals(CONNECTION_DESTROYED.toString(), notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertNotNull(notifications[1].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME)); Assert.assertEquals(connectionId, notifications[1].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME).toString()); }
@Test public void testSECURITY_PERMISSION_VIOLATION() throws Exception { SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); // guest can not create queue Role role = new Role("roleCanNotCreateQueue", true, true, false, true, false, true, true, true, true, true); Set<Role> roles = new HashSet<>(); roles.add(role); server.getSecurityRepository().addMatch(address.toString(), roles); ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager(); securityManager.getConfiguration().addRole("guest", "roleCanNotCreateQueue"); SecurityNotificationTest.flush(notifConsumer); ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); ClientSession guestSession = sf.createSession("guest", "guest", false, true, true, false, 1); try { guestSession.createQueue(address, queue, true); Assert.fail("session creation must fail and a notification of security violation must be sent"); } catch (Exception e) { } ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(SECURITY_PERMISSION_VIOLATION.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals("guest", notifications[0].getObjectProperty(ManagementHelper.HDR_USER).toString()); Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); Assert.assertEquals(CheckType.CREATE_DURABLE_QUEUE.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_CHECK_TYPE).toString()); guestSession.close(); }
@Test public void testCONSUMER_CREATED() throws Exception { SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); Role role = new Role("role", true, true, true, true, false, true, true, true, true, true); Set<Role> roles = new HashSet<>(); roles.add(role); server.getSecurityRepository().addMatch(address.toString(), roles); ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager(); securityManager.getConfiguration().addRole("guest", "role"); ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); ClientSession guestSession = sf.createSession("guest", "guest", false, true, true, false, 1); guestSession.createQueue(address, RoutingType.ANYCAST, queue, true); SecurityNotificationTest.flush(notifConsumer); guestSession.createConsumer(queue); ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(CONSUMER_CREATED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals("guest", notifications[0].getObjectProperty(ManagementHelper.HDR_USER).toString()); Assert.assertEquals("guest", notifications[0].getObjectProperty(ManagementHelper.HDR_VALIDATED_USER).toString()); Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); Assert.assertEquals(SimpleString.toSimpleString("unavailable"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_CERT_SUBJECT_DN)); guestSession.close(); }
@Test public void testCONSUMER_CLOSED() throws Exception { ClientSessionFactory sf = createSessionFactory(locator); ClientSession mySession = sf.createSession("myUser", "myPassword", false, true, true, locator.isPreAcknowledge(), locator.getAckBatchSize()); mySession.start(); SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); boolean durable = RandomUtil.randomBoolean(); mySession.createQueue(address, queue, durable); ClientConsumer consumer = mySession.createConsumer(queue); SimpleString sessionName = SimpleString.toSimpleString(((ClientSessionInternal) mySession).getName()); NotificationTest.flush(notifConsumer); consumer.close(); ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(CONSUMER_CLOSED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals(queue.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME).toString()); Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); Assert.assertEquals(0, notifications[0].getObjectProperty(ManagementHelper.HDR_CONSUMER_COUNT)); Assert.assertEquals(SimpleString.toSimpleString("myUser"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_USER)); Assert.assertEquals(SimpleString.toSimpleString("invm:0"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS)); Assert.assertEquals(sessionName, notifications[0].getSimpleStringProperty(ManagementHelper.HDR_SESSION_NAME)); session.deleteQueue(queue); }
@Test public void testCONSUMER_CREATED() throws Exception { ClientSessionFactory sf = createSessionFactory(locator); ClientSession mySession = sf.createSession("myUser", "myPassword", false, true, true, locator.isPreAcknowledge(), locator.getAckBatchSize()); mySession.start(); SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); boolean durable = RandomUtil.randomBoolean(); session.createQueue(address, queue, durable); NotificationTest.flush(notifConsumer); ClientConsumer consumer = mySession.createConsumer(queue); SimpleString consumerName = SimpleString.toSimpleString(((ClientSessionInternal) mySession).getName()); ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(CONSUMER_CREATED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertEquals(queue.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME).toString()); Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); Assert.assertEquals(1, notifications[0].getObjectProperty(ManagementHelper.HDR_CONSUMER_COUNT)); Assert.assertEquals(SimpleString.toSimpleString("myUser"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_USER)); Assert.assertEquals(null, notifications[0].getSimpleStringProperty(ManagementHelper.HDR_VALIDATED_USER)); Assert.assertEquals(SimpleString.toSimpleString("invm:0"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS)); Assert.assertEquals(consumerName, notifications[0].getSimpleStringProperty(ManagementHelper.HDR_SESSION_NAME)); Assert.assertEquals(SimpleString.toSimpleString("unavailable"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_CERT_SUBJECT_DN)); consumer.close(); session.deleteQueue(queue); }
@Test public void testMessageExpired() throws Exception { ClientSessionFactory sf = createSessionFactory(locator); ClientSession mySession = sf.createSession("myUser", "myPassword", false, true, true, locator.isPreAcknowledge(), locator.getAckBatchSize()); mySession.start(); SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); boolean durable = RandomUtil.randomBoolean(); session.createQueue(address, queue, durable); ClientConsumer consumer = mySession.createConsumer(queue); ClientProducer producer = mySession.createProducer(address); NotificationTest.flush(notifConsumer); ClientMessage msg = session.createMessage(false); msg.putStringProperty("someKey", "someValue"); msg.setExpiration(1); producer.send(msg); Thread.sleep(500); consumer.receive(500); ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(MESSAGE_EXPIRED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertNotNull(notifications[0].getObjectProperty(ManagementHelper.HDR_MESSAGE_ID)); Assert.assertEquals(address, notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS)); Assert.assertEquals(queue, notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME)); Assert.assertEquals(RoutingType.MULTICAST.getType(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_TYPE)); consumer.close(); session.deleteQueue(queue); }
@Test public void testMessageDelivered() throws Exception { ClientSessionFactory sf = createSessionFactory(locator); ClientSession mySession = sf.createSession("myUser", "myPassword", false, true, true, locator.isPreAcknowledge(), locator.getAckBatchSize()); mySession.start(); SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); boolean durable = RandomUtil.randomBoolean(); session.createQueue(address, queue, durable); ClientConsumer consumer = mySession.createConsumer(queue); ClientProducer producer = mySession.createProducer(address); NotificationTest.flush(notifConsumer); ClientMessage msg = session.createMessage(false); msg.putStringProperty("someKey", "someValue"); producer.send(msg); consumer.receive(1000); ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer); Assert.assertEquals(MESSAGE_DELIVERED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); Assert.assertNotNull(notifications[0].getObjectProperty(ManagementHelper.HDR_MESSAGE_ID)); Assert.assertNotNull(notifications[0].getObjectProperty(ManagementHelper.HDR_CONSUMER_NAME)); Assert.assertEquals(address, notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS)); Assert.assertEquals(queue, notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME)); Assert.assertEquals(RoutingType.MULTICAST.getType(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_TYPE)); consumer.close(); session.deleteQueue(queue); }