From 61aec1ba747656d2c35c2e26958ae6d1c83cdd0f Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Wed, 30 Nov 2016 14:44:15 +0000 Subject: [PATCH] ARTEMIS-789 Fix TopicDestinationResource look up on Addr --- .../artemis/rest/topic/TopicDestinationsResource.java | 11 ++++++----- .../integration/rest/RestDeserializationTest.java | 6 ++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java index af3e9c7840..641bfb8b45 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java @@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.activemq.artemis.api.core.ActiveMQException; 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.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQTopic; import org.apache.activemq.artemis.jms.server.config.TopicConfiguration; @@ -55,7 +56,7 @@ public class TopicDestinationsResource { @POST @Consumes("application/activemq.jms.topic+xml") - public Response createJmsQueue(@Context UriInfo uriInfo, Document document) { + public Response createJmsTopic(@Context UriInfo uriInfo, Document document) { ActiveMQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\""); try { @@ -65,9 +66,9 @@ public class TopicDestinationsResource { ClientSession session = manager.getSessionFactory().createSession(false, false, false); try { - ClientSession.QueueQuery query = session.queueQuery(new SimpleString(topicName)); + ClientSession.AddressQuery query = session.addressQuery(new SimpleString(topicName)); if (!query.isExists()) { - session.createQueue(topicName, topicName, "__AMQX=-1", true); + session.createAddress(SimpleString.toSimpleString(topicName), RoutingType.MULTICAST, true); } else { throw new WebApplicationException(Response.status(412).type("text/plain").entity("Queue already exists.").build()); @@ -93,13 +94,13 @@ public class TopicDestinationsResource { if (topic == null) { ClientSession session = manager.getSessionFactory().createSession(false, false, false); try { - ClientSession.QueueQuery query = session.queueQuery(new SimpleString(name)); + ClientSession.AddressQuery query = session.addressQuery(new SimpleString(name)); if (!query.isExists()) { System.err.println("Topic '" + name + "' does not exist"); throw new WebApplicationException(Response.status(404).type("text/plain").entity("Topic '" + name + "' does not exist").build()); } DestinationSettings queueSettings = manager.getDefaultSettings(); - boolean defaultDurable = queueSettings.isDurableSend() || query.isDurable(); + boolean defaultDurable = queueSettings.isDurableSend(); topic = createTopicResource(name, defaultDurable, queueSettings.getConsumerSessionTimeoutSeconds(), queueSettings.isDuplicatesAllowed()); } finally { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestDeserializationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestDeserializationTest.java index 64086e29ec..b1472a4b6f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestDeserializationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestDeserializationTest.java @@ -30,6 +30,9 @@ import java.io.File; import java.io.Serializable; import java.io.StringReader; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.server.RoutingType; +import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; import org.apache.activemq.artemis.rest.HttpHeaderProperty; @@ -82,6 +85,9 @@ public class RestDeserializationTest extends RestTestBase { @Test public void testWithoutBlackWhiteListTopic() throws Exception { + + jmsServer.getActiveMQServer().createAddressInfo(new AddressInfo(SimpleString.toSimpleString("ordersTopic"), RoutingType.MULTICAST)); + deployAndconfigureRESTService("rest-test.war"); RestMessageContext topicContext = restConnection.createTopicContext("ordersTopic");