org.apache.activemq.network
Class DemandForwardingBridgeSupport

java.lang.Object
  extended by org.apache.activemq.network.DemandForwardingBridgeSupport
All Implemented Interfaces:
Bridge, Service
Direct Known Subclasses:
CompositeDemandForwardingBridge, DemandForwardingBridge

public abstract class DemandForwardingBridgeSupport
extends java.lang.Object
implements Bridge

A useful base class for implementing demand forwarding bridges.

Version:
$Revision: 511085 $

Field Summary
protected  boolean bridgeTempDestinations
           
protected  LongSequenceGenerator consumerIdGenerator
           
protected  boolean decreaseNetworkConsumerPriority
           
protected  int demandConsumerDispatched
           
protected  ConsumerInfo demandConsumerInfo
           
protected  java.lang.String destinationFilter
           
protected  boolean dispatchAsync
           
protected  boolean disposed
           
protected  ActiveMQDestination[] durableDestinations
           
protected  ActiveMQDestination[] dynamicallyIncludedDestinations
           
protected  ActiveMQDestination[] excludedDestinations
           
protected  IdGenerator idGenerator
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean lastConnectSucceeded
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean localBridgeStarted
           
protected  Transport localBroker
           
protected  BrokerId localBrokerId
           
protected  java.lang.String localBrokerName
           
protected  BrokerId[] localBrokerPath
           
protected  java.lang.String localClientId
           
protected  ConnectionInfo localConnectionInfo
           
protected  SessionInfo localSessionInfo
           
protected static org.apache.commons.logging.Log log
           
protected  java.lang.String name
           
protected  int networkTTL
           
protected  java.lang.String password
           
protected  int prefetchSize
           
protected  ProducerInfo producerInfo
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean remoteBridgeStarted
           
protected  Transport remoteBroker
           
protected  java.lang.String remoteBrokerName
           
protected  edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch remoteBrokerNameKnownLatch
           
protected  ConnectionInfo remoteConnectionInfo
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean remoteInterupted
           
protected  edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch startedLatch
           
protected  ActiveMQDestination[] staticallyIncludedDestinations
           
protected  edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap subscriptionMapByLocalId
           
protected  edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap subscriptionMapByRemoteId
           
protected  java.lang.String userName
           
 
Constructor Summary
DemandForwardingBridgeSupport(Transport localBroker, Transport remoteBroker)
           
 
Method Summary
protected abstract  void addRemoteBrokerToBrokerPath(ConsumerInfo info)
           
protected  void addSubscription(DemandSubscription sub)
           
protected  BrokerId[] appendToBrokerPath(BrokerId[] brokerPath, BrokerId idToAppend)
           
protected  BrokerId[] appendToBrokerPath(BrokerId[] brokerPath, BrokerId[] pathsToAppend)
           
protected  void clearDownSubscriptions()
           
protected  void configureDemandSubscription(ConsumerInfo info, DemandSubscription sub)
           
protected  Message configureMessage(MessageDispatch md)
           
static boolean contains(BrokerId[] brokerPath, BrokerId brokerId)
           
protected  DemandSubscription createDemandSubscription(ActiveMQDestination destination)
           
protected  DemandSubscription createDemandSubscription(ConsumerInfo info)
           
protected abstract  NetworkBridgeFilter createNetworkBridgeFilter(ConsumerInfo info)
           
protected  DemandSubscription doCreateDemandSubscription(ConsumerInfo info)
           
protected  DemandSubscription getDemandSubscription(MessageDispatch md)
           
 ActiveMQDestination[] getDurableDestinations()
           
 ActiveMQDestination[] getDynamicallyIncludedDestinations()
           
 ActiveMQDestination[] getExcludedDestinations()
           
 Transport getLocalBroker()
           
 java.lang.String getLocalBrokerName()
           
 java.lang.String getName()
           
 int getNetworkTTL()
           
 java.lang.String getPassword()
           
 int getPrefetchSize()
           
 Transport getRemoteBroker()
           
protected abstract  BrokerId[] getRemoteBrokerPath()
           
 ActiveMQDestination[] getStaticallyIncludedDestinations()
           
 java.lang.String getUserName()
           
 boolean isBridgeTempDestinations()
           
 boolean isDecreaseNetworkConsumerPriority()
           
 boolean isDispatchAsync()
           
protected  boolean isPermissableDestination(ActiveMQDestination destination)
           
protected  void removeDemandSubscription(ConsumerId id)
           
protected  void removeSubscription(DemandSubscription sub)
           
protected abstract  void serviceLocalBrokerInfo(Command command)
           
protected  void serviceLocalCommand(Command command)
           
protected  void serviceLocalException(java.lang.Throwable error)
           
protected abstract  void serviceRemoteBrokerInfo(Command command)
           
protected  void serviceRemoteCommand(Command command)
           
protected  void serviceRemoteException(java.lang.Throwable error)
           
 void setBridgeTempDestinations(boolean bridgeTempDestinations)
           
 void setDecreaseNetworkConsumerPriority(boolean decreaseNetworkConsumerPriority)
           
 void setDispatchAsync(boolean dispatchAsync)
           
 void setDurableDestinations(ActiveMQDestination[] durableDestinations)
           
 void setDynamicallyIncludedDestinations(ActiveMQDestination[] dynamicallyIncludedDestinations)
           
 void setExcludedDestinations(ActiveMQDestination[] excludedDestinations)
           
 void setLocalBrokerName(java.lang.String localBrokerName)
           
 void setName(java.lang.String name)
           
 void setNetworkTTL(int networkTTL)
           
 void setPassword(java.lang.String password)
           
 void setPrefetchSize(int prefetchSize)
           
 void setStaticallyIncludedDestinations(ActiveMQDestination[] staticallyIncludedDestinations)
           
protected  void setupStaticDestinations()
          Subscriptions for these desitnations are always created
 void setUserName(java.lang.String userName)
           
 void start()
           
protected  void startLocalBridge()
           
protected  void startRemoteBridge()
           
 void stop()
           
protected  void triggerLocalStartBridge()
           
protected  void triggerRemoteStartBridge()
           
protected  void waitStarted()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log

localBroker

protected final Transport localBroker

remoteBroker

protected final Transport remoteBroker

idGenerator

protected final IdGenerator idGenerator

consumerIdGenerator

protected final LongSequenceGenerator consumerIdGenerator

localConnectionInfo

protected ConnectionInfo localConnectionInfo

remoteConnectionInfo

protected ConnectionInfo remoteConnectionInfo

localSessionInfo

protected SessionInfo localSessionInfo

producerInfo

protected ProducerInfo producerInfo

localBrokerName

protected java.lang.String localBrokerName

remoteBrokerName

protected java.lang.String remoteBrokerName

localClientId

protected java.lang.String localClientId

userName

protected java.lang.String userName

password

protected java.lang.String password

prefetchSize

protected int prefetchSize

dispatchAsync

protected boolean dispatchAsync

destinationFilter

protected java.lang.String destinationFilter

bridgeTempDestinations

protected boolean bridgeTempDestinations

name

protected java.lang.String name

demandConsumerInfo

protected ConsumerInfo demandConsumerInfo

demandConsumerDispatched

protected int demandConsumerDispatched

localBridgeStarted

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean localBridgeStarted

remoteBridgeStarted

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean remoteBridgeStarted

disposed

protected boolean disposed

localBrokerId

protected BrokerId localBrokerId

excludedDestinations

protected ActiveMQDestination[] excludedDestinations

dynamicallyIncludedDestinations

protected ActiveMQDestination[] dynamicallyIncludedDestinations

staticallyIncludedDestinations

protected ActiveMQDestination[] staticallyIncludedDestinations

durableDestinations

protected ActiveMQDestination[] durableDestinations

subscriptionMapByLocalId

protected final edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap subscriptionMapByLocalId

subscriptionMapByRemoteId

protected final edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap subscriptionMapByRemoteId

localBrokerPath

protected final BrokerId[] localBrokerPath

startedLatch

protected edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch startedLatch

remoteBrokerNameKnownLatch

protected edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch remoteBrokerNameKnownLatch

decreaseNetworkConsumerPriority

protected boolean decreaseNetworkConsumerPriority

networkTTL

protected int networkTTL

remoteInterupted

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean remoteInterupted

lastConnectSucceeded

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean lastConnectSucceeded
Constructor Detail

DemandForwardingBridgeSupport

public DemandForwardingBridgeSupport(Transport localBroker,
                                     Transport remoteBroker)
Method Detail

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Service
Throws:
java.lang.Exception

triggerLocalStartBridge

protected void triggerLocalStartBridge()
                                throws java.io.IOException
Throws:
java.io.IOException

triggerRemoteStartBridge

protected void triggerRemoteStartBridge()
                                 throws java.io.IOException
Throws:
java.io.IOException

startLocalBridge

protected void startLocalBridge()
                         throws java.lang.Exception
Throws:
java.lang.Exception

startRemoteBridge

protected void startRemoteBridge()
                          throws java.lang.Exception
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Service
Throws:
java.lang.Exception

serviceRemoteException

protected void serviceRemoteException(java.lang.Throwable error)

serviceRemoteCommand

protected void serviceRemoteCommand(Command command)

serviceLocalException

protected void serviceLocalException(java.lang.Throwable error)

addSubscription

protected void addSubscription(DemandSubscription sub)
                        throws java.io.IOException
Throws:
java.io.IOException

removeSubscription

protected void removeSubscription(DemandSubscription sub)
                           throws java.io.IOException
Throws:
java.io.IOException

getDemandSubscription

protected DemandSubscription getDemandSubscription(MessageDispatch md)

configureMessage

protected Message configureMessage(MessageDispatch md)

serviceLocalCommand

protected void serviceLocalCommand(Command command)

getPrefetchSize

public int getPrefetchSize()
Returns:
prefetch size

setPrefetchSize

public void setPrefetchSize(int prefetchSize)
Parameters:
prefetchSize -

isDispatchAsync

public boolean isDispatchAsync()
Returns:
true if dispatch async

setDispatchAsync

public void setDispatchAsync(boolean dispatchAsync)
Parameters:
dispatchAsync -

getDynamicallyIncludedDestinations

public ActiveMQDestination[] getDynamicallyIncludedDestinations()
Returns:
Returns the dynamicallyIncludedDestinations.

setDynamicallyIncludedDestinations

public void setDynamicallyIncludedDestinations(ActiveMQDestination[] dynamicallyIncludedDestinations)
Parameters:
dynamicallyIncludedDestinations - The dynamicallyIncludedDestinations to set.

getExcludedDestinations

public ActiveMQDestination[] getExcludedDestinations()
Returns:
Returns the excludedDestinations.

setExcludedDestinations

public void setExcludedDestinations(ActiveMQDestination[] excludedDestinations)
Parameters:
excludedDestinations - The excludedDestinations to set.

getStaticallyIncludedDestinations

public ActiveMQDestination[] getStaticallyIncludedDestinations()
Returns:
Returns the staticallyIncludedDestinations.

setStaticallyIncludedDestinations

public void setStaticallyIncludedDestinations(ActiveMQDestination[] staticallyIncludedDestinations)
Parameters:
staticallyIncludedDestinations - The staticallyIncludedDestinations to set.

getDurableDestinations

public ActiveMQDestination[] getDurableDestinations()
Returns:
Returns the durableDestinations.

setDurableDestinations

public void setDurableDestinations(ActiveMQDestination[] durableDestinations)
Parameters:
durableDestinations - The durableDestinations to set.

getLocalBrokerName

public java.lang.String getLocalBrokerName()
Returns:
Returns the localBrokerName.

setLocalBrokerName

public void setLocalBrokerName(java.lang.String localBrokerName)
Parameters:
localBrokerName - The localBrokerName to set.

getLocalBroker

public Transport getLocalBroker()
Returns:
Returns the localBroker.

getRemoteBroker

public Transport getRemoteBroker()
Returns:
Returns the remoteBroker.

getName

public java.lang.String getName()
Returns:
Returns the name.

setName

public void setName(java.lang.String name)
Parameters:
name - The name to set.

isDecreaseNetworkConsumerPriority

public boolean isDecreaseNetworkConsumerPriority()
Returns:
Returns the decreaseNetworkConsumerPriority.

setDecreaseNetworkConsumerPriority

public void setDecreaseNetworkConsumerPriority(boolean decreaseNetworkConsumerPriority)
Parameters:
decreaseNetworkConsumerPriority - The decreaseNetworkConsumerPriority to set.

getNetworkTTL

public int getNetworkTTL()
Returns:
Returns the networkTTL.

setNetworkTTL

public void setNetworkTTL(int networkTTL)
Parameters:
networkTTL - The networkTTL to set.

contains

public static boolean contains(BrokerId[] brokerPath,
                               BrokerId brokerId)

appendToBrokerPath

protected BrokerId[] appendToBrokerPath(BrokerId[] brokerPath,
                                        BrokerId[] pathsToAppend)

appendToBrokerPath

protected BrokerId[] appendToBrokerPath(BrokerId[] brokerPath,
                                        BrokerId idToAppend)

isPermissableDestination

protected boolean isPermissableDestination(ActiveMQDestination destination)

setupStaticDestinations

protected void setupStaticDestinations()
Subscriptions for these desitnations are always created


createDemandSubscription

protected DemandSubscription createDemandSubscription(ConsumerInfo info)
                                               throws java.io.IOException
Throws:
java.io.IOException

doCreateDemandSubscription

protected DemandSubscription doCreateDemandSubscription(ConsumerInfo info)
                                                 throws java.io.IOException
Throws:
java.io.IOException

createDemandSubscription

protected DemandSubscription createDemandSubscription(ActiveMQDestination destination)

configureDemandSubscription

protected void configureDemandSubscription(ConsumerInfo info,
                                           DemandSubscription sub)
                                    throws java.io.IOException
Throws:
java.io.IOException

removeDemandSubscription

protected void removeDemandSubscription(ConsumerId id)
                                 throws java.io.IOException
Throws:
java.io.IOException

waitStarted

protected void waitStarted()
                    throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

clearDownSubscriptions

protected void clearDownSubscriptions()

createNetworkBridgeFilter

protected abstract NetworkBridgeFilter createNetworkBridgeFilter(ConsumerInfo info)
                                                          throws java.io.IOException
Throws:
java.io.IOException

serviceLocalBrokerInfo

protected abstract void serviceLocalBrokerInfo(Command command)
                                        throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

addRemoteBrokerToBrokerPath

protected abstract void addRemoteBrokerToBrokerPath(ConsumerInfo info)
                                             throws java.io.IOException
Throws:
java.io.IOException

serviceRemoteBrokerInfo

protected abstract void serviceRemoteBrokerInfo(Command command)
                                         throws java.io.IOException
Throws:
java.io.IOException

getRemoteBrokerPath

protected abstract BrokerId[] getRemoteBrokerPath()

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getUserName

public java.lang.String getUserName()

setUserName

public void setUserName(java.lang.String userName)

isBridgeTempDestinations

public boolean isBridgeTempDestinations()

setBridgeTempDestinations

public void setBridgeTempDestinations(boolean bridgeTempDestinations)


Copyright © 2011 Apache Software Foundation. All Rights Reserved.