private void doBindingRemoved(final ClientMessage message) throws Exception { if (logger.isTraceEnabled()) { logger.trace(ClusterConnectionImpl.this + " Removing binding " + message); } if (!message.containsProperty(ManagementHelper.HDR_CLUSTER_NAME)) { throw new IllegalStateException("clusterName is null"); } SimpleString clusterName = message.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME); removeBinding(clusterName); }
private synchronized void doUnProposalReceived(final ClientMessage message) throws Exception { if (!message.containsProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID)) { throw new IllegalStateException("proposal type is null"); } SimpleString groupId = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID); SimpleString clusterName = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE); Integer hops = message.getIntProperty(ManagementHelper.HDR_DISTANCE); if (server.getGroupingHandler() == null) { throw new IllegalStateException("grouping handler is null"); } server.getGroupingHandler().remove(groupId, clusterName, hops + 1); }
private synchronized void doProposalResponseReceived(final ClientMessage message) throws Exception { if (!message.containsProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID)) { throw new IllegalStateException("proposal type is null"); } SimpleString type = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID); SimpleString val = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE); SimpleString alt = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_ALT_VALUE); Integer hops = message.getIntProperty(ManagementHelper.HDR_DISTANCE); Response response = new Response(type, val, alt); if (server.getGroupingHandler() == null) { throw new IllegalStateException("grouping handler is null while sending response " + response); } server.getGroupingHandler().proposed(response); server.getGroupingHandler().sendProposalResponse(response, hops + 1); }
private synchronized void doProposalReceived(final ClientMessage message) throws Exception { if (!message.containsProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID)) { throw new IllegalStateException("proposal type is null"); } SimpleString type = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID); SimpleString val = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE); Integer hops = message.getIntProperty(ManagementHelper.HDR_DISTANCE); if (server.getGroupingHandler() == null) { throw new IllegalStateException("grouping handler is null"); } Response response = server.getGroupingHandler().receive(new Proposal(type, val), hops + 1); if (response != null) { server.getGroupingHandler().sendProposalResponse(response, 0); } }
SimpleString queueAddress = message.getSimpleStringProperty(ManagementHelper.HDR_ADDRESS); SimpleString clusterName = message.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME); SimpleString routingName = message.getSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME); SimpleString filterString = message.getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING);
SimpleString clusterName = message.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME); SimpleString filterString = message.getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING);
SimpleString clusterName = message.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME); SimpleString filterString = message.getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING);
@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(); } });
private void handleNotificationMessage(ClientMessage message) throws Exception { SimpleString type = message.getSimpleStringProperty(ManagementHelper.HDR_NOTIFICATION_TYPE);
@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 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 { 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(); }
private void receiveMessages() throws Exception { ClientSession session = sf.createSession(true, true); session.start(); try (ClientConsumer consumer = session.createConsumer(ADDRESS)) { for (int i = 0; i < numMessages; i++) { ClientMessage message = consumer.receive(100); assertNotNull("Expecting a message " + i, message); assertMessageBody(i, message); assertEquals(i, message.getIntProperty("int").intValue()); assertEquals((short) i, message.getShortProperty("short").shortValue()); assertEquals((byte) i, message.getByteProperty("byte").byteValue()); assertEquals(floatValue(i), message.getFloatProperty("float").floatValue(), 0.001); assertEquals(new SimpleString(Integer.toString(i)), message.getSimpleStringProperty(SIMPLE_STRING_KEY.toString())); assertEqualsByteArrays(byteArray(i), message.getBytesProperty("byte[]")); assertTrue(message.containsProperty("null-value")); assertEquals(message.getObjectProperty("null-value"), null); message.acknowledge(); } assertNull("no more messages", consumer.receive(50)); } session.commit(); }
assertEquals(international.toString(), msg.getStringProperty("myNonAsciiStringProperty")); assertEquals(special, msg.getStringProperty("mySpecialCharacters")); assertEquals(new SimpleString("mySimpleStringPropertyValue_" + i), msg.getSimpleStringProperty(new SimpleString("mySimpleStringProperty"))); assertEquals(true, msg.getPropertyNames().contains(SimpleString.toSimpleString("myNullSimpleStringProperty"))); assertEquals(null, msg.getSimpleStringProperty("myNullSimpleStringProperty"));
Assert.assertNotNull(message); message.acknowledge(); Assert.assertNotNull(message.getSimpleStringProperty(Message.HDR_GROUP_ID)); Assert.assertNotNull("" + i, message); message.acknowledge(); Assert.assertNull(message.getSimpleStringProperty(Message.HDR_GROUP_ID)); Assert.assertNull(message.getSimpleStringProperty(Message.HDR_GROUP_ID)); Assert.assertNotNull(message); message.acknowledge(); Assert.assertNotNull(message.getSimpleStringProperty(Message.HDR_GROUP_ID));
assertNotNull(msg); msg.acknowledge(); SimpleString groupIDOnConsumer1 = msg.getSimpleStringProperty(Message.HDR_GROUP_ID);