Add a name to a bridge - so multiple bridges between the same two brokers can be used

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@380616 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2006-02-24 08:04:24 +00:00
parent 33094e694a
commit 6c1d45e1fc
3 changed files with 28 additions and 9 deletions

View File

@ -76,6 +76,7 @@ public class DemandForwardingBridge implements Bridge{
protected int prefetchSize=1000; protected int prefetchSize=1000;
protected boolean dispatchAsync; protected boolean dispatchAsync;
protected String destinationFilter=">"; protected String destinationFilter=">";
protected String name = "bridge";
protected ConsumerInfo demandConsumerInfo; protected ConsumerInfo demandConsumerInfo;
protected int demandConsumerDispatched; protected int demandConsumerDispatched;
protected AtomicBoolean localBridgeStarted=new AtomicBoolean(false); protected AtomicBoolean localBridgeStarted=new AtomicBoolean(false);
@ -173,7 +174,7 @@ public class DemandForwardingBridge implements Bridge{
if(localBridgeStarted.compareAndSet(false,true)){ if(localBridgeStarted.compareAndSet(false,true)){
localConnectionInfo=new ConnectionInfo(); localConnectionInfo=new ConnectionInfo();
localConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId())); localConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId()));
localClientId="NC_"+remoteBrokerName+"_inbound"; localClientId="NC_"+remoteBrokerName+"_inbound"+name;
localConnectionInfo.setClientId(localClientId); localConnectionInfo.setClientId(localClientId);
localBroker.oneway(localConnectionInfo); localBroker.oneway(localConnectionInfo);
localSessionInfo=new SessionInfo(localConnectionInfo,1); localSessionInfo=new SessionInfo(localConnectionInfo,1);
@ -192,7 +193,7 @@ public class DemandForwardingBridge implements Bridge{
remoteBroker.oneway(brokerInfo); remoteBroker.oneway(brokerInfo);
remoteConnectionInfo=new ConnectionInfo(); remoteConnectionInfo=new ConnectionInfo();
remoteConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId())); remoteConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId()));
remoteConnectionInfo.setClientId("NC_"+localBrokerName+"_outbound"); remoteConnectionInfo.setClientId("NC_"+localBrokerName+"_outbound"+name);
remoteBroker.oneway(remoteConnectionInfo); remoteBroker.oneway(remoteConnectionInfo);
SessionInfo remoteSessionInfo=new SessionInfo(remoteConnectionInfo,1); SessionInfo remoteSessionInfo=new SessionInfo(remoteConnectionInfo,1);
remoteBroker.oneway(remoteSessionInfo); remoteBroker.oneway(remoteSessionInfo);
@ -552,17 +553,17 @@ public class DemandForwardingBridge implements Bridge{
/** /**
* @return Returns the remoteBrokerName. * @return Returns the name.
*/ */
public String getRemoteBrokerName(){ public String getName(){
return remoteBrokerName; return name;
} }
/** /**
* @param remoteBrokerName The remoteBrokerName to set. * @param name The name to set.
*/ */
public void setRemoteBrokerName(String remoteBrokerName){ public void setName(String name){
this.remoteBrokerName=remoteBrokerName; this.name=name;
} }
/** /**
@ -783,4 +784,6 @@ public class DemandForwardingBridge implements Bridge{
} }

View File

@ -53,7 +53,7 @@ public class DurableConduitBridge extends ConduitBridge{
if(isPermissableDestination(dest) && !doesConsumerExist(dest)){ if(isPermissableDestination(dest) && !doesConsumerExist(dest)){
DemandSubscription sub=createDemandSubscription(dest); DemandSubscription sub=createDemandSubscription(dest);
if(dest.isTopic()){ if(dest.isTopic()){
sub.getLocalInfo().setSubcriptionName(getLocalBrokerName()); sub.getLocalInfo().setSubcriptionName(getLocalBrokerName()+"_"+name);
} }
try{ try{
addSubscription(sub); addSubscription(sub);

View File

@ -60,6 +60,7 @@ public class NetworkConnector implements Service, DiscoveryListener {
private boolean conduitSubscriptions = true; private boolean conduitSubscriptions = true;
private boolean decreaseNetworkConsumerPriority; private boolean decreaseNetworkConsumerPriority;
private int networkTTL = 1; private int networkTTL = 1;
private String name = "bridge";
public NetworkConnector(){ public NetworkConnector(){
@ -223,6 +224,20 @@ public class NetworkConnector implements Service, DiscoveryListener {
this.brokerName=brokerName; this.brokerName=brokerName;
} }
/**
* @return Returns the name.
*/
public String getName(){
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name){
this.name=name;
}
/** /**
* @return Returns the durableDestinations. * @return Returns the durableDestinations.
@ -392,6 +407,7 @@ public class NetworkConnector implements Service, DiscoveryListener {
}; };
} }
result.setLocalBrokerName(brokerName); result.setLocalBrokerName(brokerName);
result.setName(getBrokerName());
result.setNetworkTTL(getNetworkTTL()); result.setNetworkTTL(getNetworkTTL());
result.setDecreaseNetworkConsumerPriority(isDecreaseNetworkConsumerPriority()); result.setDecreaseNetworkConsumerPriority(isDecreaseNetworkConsumerPriority());