activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject git commit: Fix for https://issues.apache.org/jira/browse/AMQ-4825
Date Tue, 10 Dec 2013 09:10:44 GMT
Updated Branches:
  refs/heads/trunk b7c430d06 -> 71e458568


Fix for https://issues.apache.org/jira/browse/AMQ-4825


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

Branch: refs/heads/trunk
Commit: 71e45856897dd96d403e01fdf1f912b1420444c8
Parents: b7c430d
Author: rajdavies <rajdavies@gmail.com>
Authored: Tue Dec 10 09:09:21 2013 +0000
Committer: rajdavies <rajdavies@gmail.com>
Committed: Tue Dec 10 09:10:33 2013 +0000

----------------------------------------------------------------------
 .../activemq/broker/jmx/NetworkBridgeView.java  |  5 ++
 .../broker/jmx/NetworkBridgeViewMBean.java      |  2 +
 .../network/DemandForwardingBridgeSupport.java  |  5 ++
 .../apache/activemq/network/NetworkBridge.java  |  5 ++
 .../activemq/ActiveMQConnectionFactory.java     | 60 +++++++++++++++++++-
 .../org/apache/activemq/bugs/AMQ4160Test.java   |  5 ++
 6 files changed, 80 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/71e45856/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
index 47f167a..c557754 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
@@ -51,6 +51,11 @@ public class NetworkBridgeView implements NetworkBridgeViewMBean {
         return bridge.getRemoteBrokerName();
     }
 
+
+    public String getRemoteBrokerId() {
+        return bridge.getRemoteBrokerId();
+    }
+
     public String getLocalBrokerName() {
         return bridge.getLocalBrokerName();
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/71e45856/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
index b8733d1..639a81a 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
@@ -26,6 +26,8 @@ public interface NetworkBridgeViewMBean extends Service {
 
     String getRemoteBrokerName();
 
+    String getRemoteBrokerId();
+
     String getLocalBrokerName();
 
     long getEnqueueCounter();

http://git-wip-us.apache.org/repos/asf/activemq/blob/71e45856/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
index 9fa38a4..1126d22 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
@@ -1499,6 +1499,11 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge,
Br
     }
 
     @Override
+    public String getRemoteBrokerId() {
+        return (remoteBrokerInfo == null || remoteBrokerInfo.getBrokerId() ==null)? null
: remoteBrokerInfo.getBrokerId().toString();
+    }
+
+    @Override
     public String getLocalBrokerName() {
         return localBrokerInfo == null ? null : localBrokerInfo.getBrokerName();
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/71e45856/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridge.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridge.java
b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridge.java
index 95d0477..4ed03dc 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridge.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridge.java
@@ -54,6 +54,11 @@ public interface NetworkBridge extends Service {
     String getRemoteBrokerName();
 
     /**
+     * @return the id of the remote broker this bridge is connected to.
+     */
+    String getRemoteBrokerId();
+
+    /**
      * @return the network address of the local broker connection.
      */
     String getLocalAddress();

http://git-wip-us.apache.org/repos/asf/activemq/blob/71e45856/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
index 58fee6e..8495d84 100755
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
@@ -18,6 +18,8 @@ package org.apache.activemq;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -32,7 +34,6 @@ import javax.jms.QueueConnectionFactory;
 import javax.jms.TopicConnection;
 import javax.jms.TopicConnectionFactory;
 import javax.naming.Context;
-
 import org.apache.activemq.blob.BlobTransferPolicy;
 import org.apache.activemq.broker.region.policy.RedeliveryPolicyMap;
 import org.apache.activemq.jndi.JNDIBaseStorable;
@@ -48,6 +49,8 @@ import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.util.JMSExceptionSupport;
 import org.apache.activemq.util.URISupport;
 import org.apache.activemq.util.URISupport.CompositeData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A ConnectionFactory is an an Administered object, and is used for creating
@@ -59,8 +62,61 @@ import org.apache.activemq.util.URISupport.CompositeData;
  * @see javax.jms.ConnectionFactory
  */
 public class ActiveMQConnectionFactory extends JNDIBaseStorable implements ConnectionFactory,
QueueConnectionFactory, TopicConnectionFactory, StatsCapable, Cloneable {
+    private static final Logger LOG = LoggerFactory.getLogger(ActiveMQConnectionFactory.class);
+    private static final String DEFAULT_BROKER_HOST;
+    private static final int DEFAULT_BROKER_PORT;
+    static{
+        String host = null;
+        String port = null;
+        try {
+             host = AccessController.doPrivileged(new PrivilegedAction<String>() {
+                 @Override
+                 public String run() {
+                     String result = System.getProperty("org.apache.activemq.AMQ_HOST");
+                     result = (result==null||result.isEmpty()) ?  System.getProperty("AMQ_HOST","localhost")
: result;
+                     return result;
+                 }
+             });
+             port = AccessController.doPrivileged(new PrivilegedAction<String>() {
+                 @Override
+                 public String run() {
+                     String result = System.getProperty("org.apache.activemq.AMQ_PORT");
+                     result = (result==null||result.isEmpty()) ?  System.getProperty("AMQ_PORT","61616")
: result;
+                     return result;
+                 }
+             });
+        }catch(Throwable e){
+            LOG.debug("Failed to look up System properties for host and port",e);
+        }
+        host = (host == null || host.isEmpty()) ? "localhost" : host;
+        port = (port == null || port.isEmpty()) ? "61616" : port;
+        DEFAULT_BROKER_HOST = host;
+        DEFAULT_BROKER_PORT = Integer.parseInt(port);
+    }
+
+
+    public static final String DEFAULT_BROKER_BIND_URL;
+
+    static{
+        final String defaultURL = "tcp://" + DEFAULT_BROKER_HOST + ":" + DEFAULT_BROKER_PORT;
+        String bindURL = null;
+
+        try {
+            bindURL = AccessController.doPrivileged(new PrivilegedAction<String>()
{
+                @Override
+                public String run() {
+                    String result = System.getProperty("org.apache.activemq.BROKER_BIND_URL");
+                    result = (result==null||result.isEmpty()) ?  System.getProperty("BROKER_BIND_URL",defaultURL)
: result;
+                    return result;
+                }
+            });
+        }catch(Throwable e){
+            LOG.debug("Failed to look up System properties for host and port",e);
+        }
+        bindURL = (bindURL == null || bindURL.isEmpty()) ? defaultURL : bindURL;
+        DEFAULT_BROKER_BIND_URL = bindURL;
+    }
 
-    public static final String DEFAULT_BROKER_BIND_URL = "tcp://localhost:61616";
     public static final String DEFAULT_BROKER_URL = "failover://"+DEFAULT_BROKER_BIND_URL;
     public static final String DEFAULT_USER = null;
     public static final String DEFAULT_PASSWORD = null;

http://git-wip-us.apache.org/repos/asf/activemq/blob/71e45856/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4160Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4160Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4160Test.java
index 34bff2d..4867f28 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4160Test.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4160Test.java
@@ -303,6 +303,11 @@ public class AMQ4160Test extends JmsMultipleBrokersTestSupport {
                     }
 
                     @Override
+                    public String getRemoteBrokerId() {
+                        return next.getRemoteBrokerId();
+                    }
+
+                    @Override
                     public String getLocalAddress() {
                         return next.getLocalAddress();
                     }


Mime
View raw message