This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 676bb10  ARTEMIS-2896 RA can double legacy prefix
     new ae5535b  This closes #3256
676bb10 is described below

commit 676bb101d8f4450fe3a39b63da8bc471706ab7ff
Author: Justin Bertram <[email protected]>
AuthorDate: Tue Sep 8 11:31:48 2020 -0500

    ARTEMIS-2896 RA can double legacy prefix
---
 .../artemis/ra/inflow/ActiveMQMessageHandler.java  |  2 +-
 .../integration/ra/ActiveMQMessageHandlerTest.java | 32 ++++++++++++++++++----
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git 
a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java
 
b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java
index 68bfe14..714277f 100644
--- 
a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java
+++ 
b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java
@@ -141,7 +141,7 @@ public class ActiveMQMessageHandler implements 
MessageHandler, FailoverEventList
 
             boolean selectorChanged = selector == null && oldFilterString != 
null || oldFilterString == null && selector != null || (oldFilterString != null 
&& selector != null && !oldFilterString.toString().equals(selector));
 
-            SimpleString oldTopicName = (enable1XPrefix ? 
PacketImpl.OLD_TOPIC_PREFIX : 
SimpleString.toSimpleString("")).concat(subResponse.getAddress());
+            SimpleString oldTopicName = (enable1XPrefix && 
!subResponse.getAddress().startsWith(PacketImpl.OLD_TOPIC_PREFIX) ? 
PacketImpl.OLD_TOPIC_PREFIX : 
SimpleString.toSimpleString("")).concat(subResponse.getAddress());
 
             boolean topicChanged = 
!oldTopicName.equals(activation.getAddress());
 
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java
index 776187c..513c7ef 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java
@@ -87,16 +87,28 @@ public class ActiveMQMessageHandlerTest extends 
ActiveMQRATestBase {
 
    @Test
    public void testDurableTopicSubscriptionWith1xPrefixesOnSpec() throws 
Exception {
-      internalTestDurableTopicSubscriptionWith1xPrefixes(false);
+      internalTestDurableTopicSubscriptionWith1xPrefixes(false, true);
    }
 
    @Test
    public void testDurableTopicSubscriptionWith1xPrefixesOnRA() throws 
Exception {
-      internalTestDurableTopicSubscriptionWith1xPrefixes(true);
+      internalTestDurableTopicSubscriptionWith1xPrefixes(true, true);
    }
 
-   public void internalTestDurableTopicSubscriptionWith1xPrefixes(boolean ra) 
throws Exception {
-      server.getRemotingService().createAcceptor("test", 
"tcp://localhost:61617?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.").start();
+   @Test
+   public void 
testDurableTopicSubscriptionWith1xPrefixesOnSpecWithoutBrokerPrefixes() throws 
Exception {
+      internalTestDurableTopicSubscriptionWith1xPrefixes(false, false);
+   }
+
+   @Test
+   public void 
testDurableTopicSubscriptionWith1xPrefixesOnRAWithoutBrokerPrefixes() throws 
Exception {
+      internalTestDurableTopicSubscriptionWith1xPrefixes(true, false);
+   }
+
+   public void internalTestDurableTopicSubscriptionWith1xPrefixes(boolean ra, 
boolean definePrefixesOnBroker) throws Exception {
+      if (definePrefixesOnBroker) {
+         server.getRemotingService().createAcceptor("test", 
"tcp://localhost:61617?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.").start();
+      }
       ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
       if (ra) {
          qResourceAdapter.setEnable1xPrefixes(true);
@@ -117,13 +129,21 @@ public class ActiveMQMessageHandlerTest extends 
ActiveMQRATestBase {
       spec.setClientId("myClientId");
       spec.setSubscriptionName("mySubscriptionName");
       qResourceAdapter.setConnectorClassName(NETTY_CONNECTOR_FACTORY);
-      qResourceAdapter.setConnectionParameters("host=localhost;port=61617");
+      String port = "61616";
+      if (definePrefixesOnBroker) {
+         port = "61617";
+      }
+      qResourceAdapter.setConnectionParameters("host=localhost;port=" + port);
       CountDownLatch latch = new CountDownLatch(1);
       DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
       DummyMessageEndpointFactory endpointFactory = new 
DummyMessageEndpointFactory(endpoint, false);
       qResourceAdapter.endpointActivation(endpointFactory, spec);
       ClientSession session = locator.createSessionFactory().createSession();
-      ClientProducer clientProducer = session.createProducer("MyTopic");
+      String topic = "MyTopic";
+      if (!definePrefixesOnBroker) {
+         topic = "jms.topic." + topic;
+      }
+      ClientProducer clientProducer = session.createProducer(topic);
       ClientMessage message = session.createMessage(true);
       message.getBodyBuffer().writeString("teststring");
       clientProducer.send(message);

Reply via email to