From 3abfd9f552be52ef98505a2922cfebdb70b350e2 Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Wed, 30 Nov 2016 12:49:38 +0000 Subject: [PATCH] ARTEMIS-877 Updates to REST module --- .../artemis/rest/queue/QueueServiceManager.java | 11 +++++++++-- .../artemis/rest/topic/TopicServiceManager.java | 11 +++++------ .../activemq/artemis/rest/test/SelectorTest.java | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java index a606044c7a..170285a933 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.core.server.RoutingType; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; import org.apache.activemq.artemis.rest.queue.push.FilePushStore; import org.apache.activemq.artemis.rest.queue.push.PushStore; @@ -82,9 +83,15 @@ public class QueueServiceManager extends DestinationServiceManager { } String queueName = queueDeployment.getName(); try (ClientSession session = sessionFactory.createSession(false, false, false)) { - ClientSession.QueueQuery query = session.queueQuery(new SimpleString(queueName)); + ClientSession.AddressQuery query = session.addressQuery(SimpleString.toSimpleString(queueName)); if (!query.isExists()) { - session.createQueue(queueName, queueName, queueDeployment.isDurableSend()); + session.createAddress(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, true); + session.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), queueDeployment.isDurableSend()); + } else { + ClientSession.QueueQuery qquery = session.queueQuery(SimpleString.toSimpleString(queueName)); + if (!qquery.isExists()) { + session.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), queueDeployment.isDurableSend()); + } } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java index 1b710ee857..8944ecf8d6 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.core.server.RoutingType; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; import org.apache.activemq.artemis.rest.queue.DestinationServiceManager; @@ -83,14 +84,12 @@ public class TopicServiceManager extends DestinationServiceManager { } String queueName = topicDeployment.getName(); boolean defaultDurable; + try (ClientSession session = sessionFactory.createSession(false, false, false)) { - ClientSession.QueueQuery query = session.queueQuery(new SimpleString(queueName)); defaultDurable = topicDeployment.isDurableSend(); - if (query.isExists()) { - defaultDurable = query.isDurable(); - } else { - session.createQueue(queueName, queueName, topicDeployment.isDurableSend()); - } + ClientSession.AddressQuery query = session.addressQuery(new SimpleString(queueName)); + if (!query.isExists()) + session.createAddress(SimpleString.toSimpleString(queueName), RoutingType.MULTICAST, true); } destination.createTopicResource(queueName, defaultDurable, topicDeployment.getConsumerSessionTimeoutSeconds(), topicDeployment.isDuplicatesAllowed()); diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SelectorTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SelectorTest.java index 1491f51a50..245d25cf5f 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SelectorTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SelectorTest.java @@ -46,7 +46,7 @@ public class SelectorTest extends MessageTestBase { public static ConnectionFactory connectionFactory; public static String topicName = "testTopic"; - public static String prefixedTopicName = ActiveMQDestination.createQueueAddressFromName(topicName).toString(); + public static String prefixedTopicName = ActiveMQDestination.createTopicAddressFromName(topicName).toString(); @BeforeClass public static void setup() throws Exception {