activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [1/2] activemq git commit: https://issues.apache.org/jira/browse/AMQ-5705
Date Wed, 17 Jun 2015 21:16:33 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 428fc82c8 -> 829e6fb0e


https://issues.apache.org/jira/browse/AMQ-5705

Modifing the AdivsoryBroker to set the originBrokerURL to the transport connector's
URL if it has been set versus using a default URL.


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

Branch: refs/heads/master
Commit: fc3e0261229bb90edbcf4eaeabc5ee2e1b57894d
Parents: 428fc82
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Wed Jun 17 17:47:24 2015 +0000
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Wed Jun 17 17:47:24 2015 +0000

----------------------------------------------------------------------
 .../activemq/advisory/AdvisoryBroker.java       |  8 ++++++-
 .../apache/activemq/advisory/AdvisoryTests.java | 22 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/fc3e0261/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
b/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
index 7a6915d..36f5f0b 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
@@ -31,6 +31,7 @@ import org.apache.activemq.broker.BrokerFilter;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.ProducerBrokerExchange;
+import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.broker.region.BaseDestination;
 import org.apache.activemq.broker.region.Destination;
 import org.apache.activemq.broker.region.DurableTopicSubscription;
@@ -627,7 +628,12 @@ public class AdvisoryBroker extends BrokerFilter {
             advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_ID,
id);
 
             String url = getBrokerService().getVmConnectorURI().toString();
-            if (getBrokerService().getDefaultSocketURIString() != null) {
+            //try and find the URL on the transport connector and use if it exists else
+            //try and find a default URL
+            if (context.getConnector() instanceof TransportConnector
+                    && ((TransportConnector) context.getConnector()).getPublishableConnectString()
!= null) {
+                url = ((TransportConnector) context.getConnector()).getPublishableConnectString();
+            } else if (getBrokerService().getDefaultSocketURIString() != null) {
                 url = getBrokerService().getDefaultSocketURIString();
             }
             advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL,
url);

http://git-wip-us.apache.org/repos/asf/activemq/blob/fc3e0261/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
index ce072aa..0863b31 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
@@ -19,6 +19,7 @@ package org.apache.activemq.advisory;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -147,6 +148,11 @@ public class AdvisoryTests {
         assertNotNull(msg);
         ActiveMQMessage message = (ActiveMQMessage) msg;
         ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
+
+        //This should always be tcp:// because that is the transport that is used to connect
even though
+        //the nio transport is the first one in the list
+        assertTrue(((String)message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL)).startsWith("tcp://"));
+
         //Add assertion to make sure body is included for advisory topics
         //when includeBodyForAdvisory is true
         assertIncludeBodyForAdvisory(payload);
@@ -177,6 +183,11 @@ public class AdvisoryTests {
         ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
         String originalId = payload.getJMSMessageID();
         assertEquals(originalId, id);
+
+        //This should always be tcp:// because that is the transport that is used to connect
even though
+        //the nio transport is the first one in the list
+        assertTrue(((String)message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL)).startsWith("tcp://"));
+
         //Add assertion to make sure body is included for advisory topics
         //when includeBodyForAdvisory is true
         assertIncludeBodyForAdvisory(payload);
@@ -204,6 +215,10 @@ public class AdvisoryTests {
         assertNotNull(msg);
         ActiveMQMessage message = (ActiveMQMessage) msg;
         ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
+
+        //This should be set
+        assertNotNull(message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL));
+
         //Add assertion to make sure body is included for advisory topics
         //when includeBodyForAdvisory is true
         assertIncludeBodyForAdvisory(payload);
@@ -235,6 +250,8 @@ public class AdvisoryTests {
         assertNotNull(msg);
         ActiveMQMessage message = (ActiveMQMessage) msg;
         ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
+        //This should be set
+        assertNotNull(message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL));
         //Add assertion to make sure body is included for DLQ advisory topics
         //when includeBodyForAdvisory is true
         assertIncludeBodyForAdvisory(payload);
@@ -265,6 +282,10 @@ public class AdvisoryTests {
         assertNotNull(msg);
         ActiveMQMessage message = (ActiveMQMessage) msg;
         ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
+
+        //This should be set
+        assertNotNull(message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL));
+
         //Add assertion to make sure body is included for advisory topics
         //when includeBodyForAdvisory is true
         assertIncludeBodyForAdvisory(payload);
@@ -319,6 +340,7 @@ public class AdvisoryTests {
         pMap.setDefaultEntry(policy);
 
         answer.setDestinationPolicy(pMap);
+        answer.addConnector("nio://localhost:0");
         answer.addConnector(bindAddress);
         answer.setDeleteAllMessagesOnStartup(true);
     }


Mime
View raw message