You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2018/08/09 23:35:53 UTC

activemq-artemis git commit: ARTEMIS-2020 Use prefixes when useJNDI=false in RA

Repository: activemq-artemis
Updated Branches:
  refs/heads/2.6.x 2c20fe471 -> 17cde4d87


ARTEMIS-2020 Use prefixes when useJNDI=false in RA

(cherry picked from commit 1171f01b30468abfa4d6f2de6401802ad59d4c4f)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/17cde4d8
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/17cde4d8
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/17cde4d8

Branch: refs/heads/2.6.x
Commit: 17cde4d87e5d66c8703802e4b1d7c68b08900c0f
Parents: 2c20fe4
Author: Justin Bertram <jb...@apache.org>
Authored: Thu Aug 9 11:20:46 2018 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Aug 9 19:35:47 2018 -0400

----------------------------------------------------------------------
 .../artemis/ra/inflow/ActiveMQActivation.java   |  4 +-
 .../integration/ra/ResourceAdapterTest.java     | 65 ++++++++++++++++++++
 2 files changed, 67 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/17cde4d8/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java
----------------------------------------------------------------------
diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java
index ede1b01..3a89369 100644
--- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java
+++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java
@@ -572,10 +572,10 @@ public class ActiveMQActivation {
          ActiveMQRALogger.LOGGER.instantiatingDestination(spec.getDestinationType(), spec.getDestination());
 
          if (Topic.class.getName().equals(spec.getDestinationType())) {
-            destination = (ActiveMQDestination) ActiveMQJMSClient.createTopic(spec.getDestination());
+            destination = (ActiveMQDestination) ActiveMQJMSClient.createTopic((spec.getTopicPrefix() == null ? "" : spec.getTopicPrefix()) + spec.getDestination());
             isTopic = true;
          } else {
-            destination = (ActiveMQDestination) ActiveMQJMSClient.createQueue(spec.getDestination());
+            destination = (ActiveMQDestination) ActiveMQJMSClient.createQueue((spec.getQueuePrefix() == null ? "" : spec.getQueuePrefix()) + spec.getDestination());
          }
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/17cde4d8/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
index 811cc29..6216bb3 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
@@ -26,12 +26,17 @@ import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.management.AddressControl;
+import org.apache.activemq.artemis.api.core.management.ResourceNames;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
 import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
+import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
 import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter;
@@ -101,6 +106,66 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
    }
 
    @Test
+   public void testQueuePrefixWhenUseJndiIsFalse() throws Exception {
+      final String prefix = "jms.queue.";
+      final String destinationName = "test";
+      final SimpleString prefixedDestinationName = SimpleString.toSimpleString(prefix + destinationName);
+      server.createQueue(prefixedDestinationName, RoutingType.ANYCAST, prefixedDestinationName, null, false, false);
+      ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
+      ra.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+      ra.start(new BootstrapContext());
+      Connection conn = ra.getDefaultActiveMQConnectionFactory().createConnection();
+      conn.close();
+
+      ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
+      spec.setResourceAdapter(ra);
+      spec.setUseJNDI(false);
+      spec.setDestinationType("javax.jms.Queue");
+      spec.setDestination(destinationName);
+      spec.setQueuePrefix(prefix);
+      spec.setMaxSession(1);
+      spec.setSetupAttempts(1);
+
+      ActiveMQActivation activation = new ActiveMQActivation(ra, new MessageEndpointFactory(), spec);
+
+      activation.start();
+
+      assertEquals(1, server.locateQueue(prefixedDestinationName).getConsumerCount());
+
+      activation.stop();
+   }
+
+   @Test
+   public void testTopicPrefixWhenUseJndiIsFalse() throws Exception {
+      final String prefix = "jms.topic.";
+      final String destinationName = "test";
+      final SimpleString prefixedDestinationName = SimpleString.toSimpleString(prefix + destinationName);
+      server.addAddressInfo(new AddressInfo(prefixedDestinationName).addRoutingType(RoutingType.MULTICAST));
+      ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
+      ra.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+      ra.start(new BootstrapContext());
+      Connection conn = ra.getDefaultActiveMQConnectionFactory().createConnection();
+      conn.close();
+
+      ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
+      spec.setResourceAdapter(ra);
+      spec.setUseJNDI(false);
+      spec.setDestinationType("javax.jms.Topic");
+      spec.setDestination(destinationName);
+      spec.setTopicPrefix(prefix);
+      spec.setMaxSession(1);
+      spec.setSetupAttempts(1);
+
+      ActiveMQActivation activation = new ActiveMQActivation(ra, new MessageEndpointFactory(), spec);
+
+      activation.start();
+
+      assertEquals(1, ((AddressControl)server.getManagementService().getResource(ResourceNames.ADDRESS + prefixedDestinationName)).getQueueNames().length);
+
+      activation.stop();
+   }
+
+   @Test
    public void testStartStop() throws Exception {
       ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
       qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);