This commit is contained in:
rajdavies 2013-12-10 09:09:21 +00:00
parent b7c430d068
commit 71e4585689
6 changed files with 80 additions and 2 deletions

View File

@ -51,6 +51,11 @@ public class NetworkBridgeView implements NetworkBridgeViewMBean {
return bridge.getRemoteBrokerName();
}
public String getRemoteBrokerId() {
return bridge.getRemoteBrokerId();
}
public String getLocalBrokerName() {
return bridge.getLocalBrokerName();
}

View File

@ -26,6 +26,8 @@ public interface NetworkBridgeViewMBean extends Service {
String getRemoteBrokerName();
String getRemoteBrokerId();
String getLocalBrokerName();
long getEnqueueCounter();

View File

@ -1498,6 +1498,11 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
return remoteBrokerInfo == null ? null : remoteBrokerInfo.getBrokerName();
}
@Override
public String getRemoteBrokerId() {
return (remoteBrokerInfo == null || remoteBrokerInfo.getBrokerId() ==null)? null : remoteBrokerInfo.getBrokerId().toString();
}
@Override
public String getLocalBrokerName() {
return localBrokerInfo == null ? null : localBrokerInfo.getBrokerName();

View File

@ -53,6 +53,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.
*/

View File

@ -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;

View File

@ -302,6 +302,11 @@ public class AMQ4160Test extends JmsMultipleBrokersTestSupport {
return next.getRemoteBrokerName();
}
@Override
public String getRemoteBrokerId() {
return next.getRemoteBrokerId();
}
@Override
public String getLocalAddress() {
return next.getLocalAddress();