@Test public void testAMQPSenderHonourRoutingTypeOfExistingAddress() throws Exception { RoutingType routingType = server.getConfiguration().getAddressesSettings().get("#").getDefaultAddressRoutingType(); Assert.assertEquals(RoutingType.ANYCAST, routingType); try (ActiveMQConnection coreConnection = (ActiveMQConnection) createCoreConnection(); ClientSession clientSession = coreConnection.getSessionFactory().createSession()) { RoutingType addressRoutingType = RoutingType.MULTICAST; SimpleString address = SimpleString.toSimpleString("myTopic_" + UUID.randomUUID().toString()); clientSession.createAddress(address, addressRoutingType, false); ClientSession.AddressQuery addressQuery = clientSession.addressQuery(address); Assert.assertTrue(addressQuery.isExists()); Assert.assertTrue(addressQuery.getQueueNames().isEmpty()); AmqpClient client = createAmqpClient(guestUser, guestPass); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); AmqpSender sender = session.createSender(address.toString()); try { ClientSession.QueueQuery queueQuery = clientSession.queueQuery(address); Assert.assertFalse(queueQuery.isExists()); Assert.assertEquals(addressRoutingType, queueQuery.getRoutingType()); } finally { sender.close(); session.close(); connection.close(); } } }
@Test public void testAMQPSenderCreateQueueWithDefaultRoutingTypeIfAddressDoNotExist() throws Exception { RoutingType defaultRoutingType = server.getConfiguration().getAddressesSettings().get("#").getDefaultAddressRoutingType(); Assert.assertEquals(RoutingType.ANYCAST, defaultRoutingType); try (ActiveMQConnection coreConnection = (ActiveMQConnection) createCoreConnection(); ClientSession clientSession = coreConnection.getSessionFactory().createSession()) { SimpleString address = SimpleString.toSimpleString("myTopic_" + UUID.randomUUID().toString()); ClientSession.AddressQuery addressQuery = clientSession.addressQuery(address); Assert.assertFalse(addressQuery.isExists()); Assert.assertTrue(addressQuery.getQueueNames().isEmpty()); AmqpClient client = createAmqpClient(guestUser, guestPass); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); AmqpSender sender = session.createSender(address.toString()); try { addressQuery = clientSession.addressQuery(address); Assert.assertTrue(addressQuery.isExists()); Assert.assertThat(addressQuery.getQueueNames(), CoreMatchers.hasItem(address)); ClientSession.QueueQuery queueQuery = clientSession.queueQuery(address); Assert.assertTrue(queueQuery.isExists()); Assert.assertEquals(defaultRoutingType, queueQuery.getRoutingType()); } finally { sender.close(); session.close(); connection.close(); } } } }
CreateQueueMessage_V2 createQueueRequest = new CreateQueueMessage_V2(queueInfo.getAddress(), queueInfo.getName(), queueInfo.getRoutingType(), queueInfo.getFilterString(), queueInfo.isDurable(), queueInfo.isTemporary(), queueInfo.getMaxConsumers(), queueInfo.isPurgeOnNoConsumers(), queueInfo.isAutoCreated(), false, queueInfo.isExclusive(), queueInfo.isLastValue());
CreateQueueMessage_V2 createQueueRequest = new CreateQueueMessage_V2(queueInfo.getAddress(), queueInfo.getName(), queueInfo.getRoutingType(), queueInfo.getFilterString(), queueInfo.isDurable(), queueInfo.isTemporary(), queueInfo.getMaxConsumers(), queueInfo.isPurgeOnNoConsumers(), queueInfo.isAutoCreated(), false, queueInfo.isExclusive(), queueInfo.isLastValue());
CreateQueueMessage_V2 createQueueRequest = new CreateQueueMessage_V2(queueInfo.getAddress(), queueInfo.getName(), queueInfo.getRoutingType(), queueInfo.getFilterString(), queueInfo.isDurable(), queueInfo.isTemporary(), queueInfo.getMaxConsumers(), queueInfo.isPurgeOnNoConsumers(), queueInfo.isAutoCreated(), false, queueInfo.isExclusive(), queueInfo.isLastValue(), queueInfo.getLastValueKey(), queueInfo.isNonDestructive(), queueInfo.getConsumersBeforeDispatch(), queueInfo.getDelayBeforeDispatch());
CreateQueueMessage_V2 createQueueRequest = new CreateQueueMessage_V2(queueInfo.getAddress(), queueInfo.getName(), queueInfo.getRoutingType(), queueInfo.getFilterString(), queueInfo.isDurable(), queueInfo.isTemporary(), queueInfo.getMaxConsumers(), queueInfo.isPurgeOnNoConsumers(), queueInfo.isAutoCreated(), false, queueInfo.isExclusive(), queueInfo.isLastValue(), queueInfo.getLastValueKey(), queueInfo.isNonDestructive(), queueInfo.getConsumersBeforeDispatch(), queueInfo.getDelayBeforeDispatch());
CreateQueueMessage_V2 createQueueRequest = new CreateQueueMessage_V2(queueInfo.getAddress(), queueInfo.getName(), queueInfo.getRoutingType(), queueInfo.getFilterString(), queueInfo.isDurable(), queueInfo.isTemporary(), queueInfo.getMaxConsumers(), queueInfo.isPurgeOnNoConsumers(), queueInfo.isAutoCreated(), false, queueInfo.isExclusive(), queueInfo.isLastValue());
CreateQueueMessage_V2 createQueueRequest = new CreateQueueMessage_V2(queueInfo.getAddress(), queueInfo.getName(), queueInfo.getRoutingType(), queueInfo.getFilterString(), queueInfo.isDurable(), queueInfo.isTemporary(), queueInfo.getMaxConsumers(), queueInfo.isPurgeOnNoConsumers(), queueInfo.isAutoCreated(), false, queueInfo.isExclusive(), queueInfo.isLastValue(), queueInfo.getLastValueKey(), queueInfo.isNonDestructive(), queueInfo.getConsumersBeforeDispatch(), queueInfo.getDelayBeforeDispatch());
CreateQueueMessage_V2 createQueueRequest = new CreateQueueMessage_V2(queueInfo.getAddress(), queueInfo.getName(), queueInfo.getRoutingType(), queueInfo.getFilterString(), queueInfo.isDurable(), queueInfo.isTemporary(), queueInfo.getMaxConsumers(), queueInfo.isPurgeOnNoConsumers(), queueInfo.isAutoCreated(), false, queueInfo.isExclusive(), queueInfo.isLastValue());