From d1a687a98f24d6ad6dce9e9659cf0d447221befa Mon Sep 17 00:00:00 2001 From: jbertram Date: Fri, 29 Apr 2016 12:04:14 -0500 Subject: [PATCH] ARTEMIS-510 create queue only on route --- .../activemq/artemis/jms/client/ActiveMQSession.java | 9 ++------- .../tests/integration/client/AutoCreateJmsQueueTest.java | 9 +++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java index 33209320fb..50269f51c6 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java @@ -298,13 +298,8 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (jbd != null) { ClientSession.AddressQuery response = session.addressQuery(jbd.getSimpleAddress()); - if (!response.isExists()) { - if (response.isAutoCreateJmsQueues()) { - session.createQueue(jbd.getSimpleAddress(), jbd.getSimpleAddress(), true); - } - else { - throw new InvalidDestinationException("Destination " + jbd.getName() + " does not exist"); - } + if (!response.isExists() && !response.isAutoCreateJmsQueues()) { + throw new InvalidDestinationException("Destination " + jbd.getName() + " does not exist"); } connection.addKnownDestination(jbd.getSimpleAddress()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsQueueTest.java index 4c29d6cba7..91878c86be 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsQueueTest.java @@ -66,6 +66,9 @@ public class AutoCreateJmsQueueTest extends JMSTestBase { } connection.close(); + + // make sure the JMX control was created for the JMS queue + assertNotNull(server.getManagementService().getResource("jms.queue.test")); } @Test @@ -110,10 +113,12 @@ public class AutoCreateJmsQueueTest extends JMSTestBase { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); javax.jms.Queue queue = ActiveMQJMSClient.createQueue("test"); + MessageProducer producer = session.createProducer(queue); + TextMessage mess = session.createTextMessage("msg"); try { - MessageProducer producer = session.createProducer(queue); - Assert.fail("Creating a producer here should throw a JMSSecurityException"); + producer.send(mess); + Assert.fail("Sending a message here should throw a JMSSecurityException"); } catch (Exception e) { Assert.assertTrue(e instanceof JMSSecurityException);