org.apache.activemq.network
Class DemandForwardingBridgeSupport

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

public abstract class DemandForwardingBridgeSupport
extends java.lang.Object
implements NetworkBridge, BrokerServiceAware

A useful base class for implementing demand forwarding bridges.


Field Summary
protected  java.lang.Object brokerInfoMutex
           
protected  NetworkBridgeConfiguration configuration
           
protected  LongSequenceGenerator consumerIdGenerator
           
protected  NetworkBridgeFilterFactory defaultFilterFactory
           
protected  int demandConsumerDispatched
           
protected  ConsumerInfo demandConsumerInfo
           
protected  java.util.concurrent.atomic.AtomicBoolean disposed
           
protected static java.lang.String DURABLE_SUB_PREFIX
           
protected  ActiveMQDestination[] durableDestinations
           
protected  ActiveMQDestination[] dynamicallyIncludedDestinations
           
protected  ActiveMQDestination[] excludedDestinations
           
protected  IdGenerator idGenerator
           
protected  java.util.concurrent.atomic.AtomicBoolean lastConnectSucceeded
           
protected  java.util.concurrent.atomic.AtomicBoolean localBridgeStarted
           
protected  Transport localBroker
           
protected  BrokerId localBrokerId
           
protected  BrokerId[] localBrokerPath
           
protected  java.lang.String localClientId
           
protected  ConnectionInfo localConnectionInfo
           
protected  SessionInfo localSessionInfo
           
protected  java.util.concurrent.CountDownLatch localStartedLatch
           
protected  ProducerInfo producerInfo
           
protected  java.util.concurrent.atomic.AtomicBoolean remoteBridgeStarted
           
protected  Transport remoteBroker
           
protected  BrokerId remoteBrokerId
           
protected  java.lang.String remoteBrokerName
           
protected  BrokerId[] remoteBrokerPath
           
protected  ConnectionInfo remoteConnectionInfo
           
protected  java.util.concurrent.CountDownLatch startedLatch
           
protected  ActiveMQDestination[] staticallyIncludedDestinations
           
protected  java.util.concurrent.ConcurrentHashMap<ConsumerId,DemandSubscription> subscriptionMapByLocalId
           
protected  java.util.concurrent.ConcurrentHashMap<ConsumerId,DemandSubscription> subscriptionMapByRemoteId
           
 
Constructor Summary
DemandForwardingBridgeSupport(NetworkBridgeConfiguration configuration, Transport localBroker, Transport remoteBroker)
           
 
Method Summary
protected  boolean addConsumerInfo(ConsumerInfo consumerInfo)
           
protected  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  NetworkBridgeFilter createNetworkBridgeFilter(ConsumerInfo info)
           
protected  DemandSubscription doCreateDemandSubscription(ConsumerInfo info)
           
 void duplexStart(TransportConnection connection, BrokerInfo localBrokerInfo, BrokerInfo remoteBrokerInfo)
           
protected  Service getControllingService()
           
 long getDequeueCounter()
           
 ActiveMQDestination[] getDurableDestinations()
           
 ActiveMQDestination[] getDynamicallyIncludedDestinations()
           
 long getEnqueueCounter()
           
 ActiveMQDestination[] getExcludedDestinations()
           
 java.lang.String getLocalAddress()
           
 Transport getLocalBroker()
           
 java.lang.String getLocalBrokerName()
           
 java.util.concurrent.ConcurrentHashMap<ConsumerId,DemandSubscription> getLocalSubscriptionMap()
           
 javax.management.ObjectName getMbeanObjectName()
           
 java.lang.String getRemoteAddress()
           
 Transport getRemoteBroker()
           
 java.lang.String getRemoteBrokerName()
           
protected  BrokerId[] getRemoteBrokerPath()
           
 ActiveMQDestination[] getStaticallyIncludedDestinations()
           
 boolean isCreatedByDuplex()
           
protected  boolean isDuplex()
           
protected  boolean isPermissableDestination(ActiveMQDestination destination)
           
protected  boolean isPermissableDestination(ActiveMQDestination destination, boolean allowTemporary)
           
protected  void removeDemandSubscription(ConsumerId id)
           
protected  boolean removeDemandSubscriptionByLocalId(ConsumerId consumerId)
           
protected  void removeSubscription(DemandSubscription sub)
           
protected  void serviceLocalBrokerInfo(Command command)
           
protected  void serviceLocalCommand(Command command)
           
 void serviceLocalException(java.lang.Throwable error)
          servicee an exception
protected  void serviceRemoteBrokerInfo(Command command)
           
protected  void serviceRemoteCommand(Command command)
           
 void serviceRemoteException(java.lang.Throwable error)
          Service an exception
 void setBrokerService(BrokerService brokerService)
           
 void setCreatedByDuplex(boolean createdByDuplex)
           
 void setDurableDestinations(ActiveMQDestination[] durableDestinations)
           
 void setDynamicallyIncludedDestinations(ActiveMQDestination[] dynamicallyIncludedDestinations)
           
 void setExcludedDestinations(ActiveMQDestination[] excludedDestinations)
           
 void setMbeanObjectName(javax.management.ObjectName objectName)
           
 void setNetworkBridgeListener(NetworkBridgeListener listener)
          Set the NetworkBridgeFailedListener
 void setStaticallyIncludedDestinations(ActiveMQDestination[] staticallyIncludedDestinations)
           
protected  void setupStaticDestinations()
          Subscriptions for these destinations are always created
 void start()
           
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

DURABLE_SUB_PREFIX

protected static final java.lang.String DURABLE_SUB_PREFIX
See Also:
Constant Field Values

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

remoteBrokerName

protected java.lang.String remoteBrokerName

localClientId

protected java.lang.String localClientId

demandConsumerInfo

protected ConsumerInfo demandConsumerInfo

demandConsumerDispatched

protected int demandConsumerDispatched

localBridgeStarted

protected final java.util.concurrent.atomic.AtomicBoolean localBridgeStarted

remoteBridgeStarted

protected final java.util.concurrent.atomic.AtomicBoolean remoteBridgeStarted

disposed

protected java.util.concurrent.atomic.AtomicBoolean disposed

localBrokerId

protected BrokerId localBrokerId

excludedDestinations

protected ActiveMQDestination[] excludedDestinations

dynamicallyIncludedDestinations

protected ActiveMQDestination[] dynamicallyIncludedDestinations

staticallyIncludedDestinations

protected ActiveMQDestination[] staticallyIncludedDestinations

durableDestinations

protected ActiveMQDestination[] durableDestinations

subscriptionMapByLocalId

protected final java.util.concurrent.ConcurrentHashMap<ConsumerId,DemandSubscription> subscriptionMapByLocalId

subscriptionMapByRemoteId

protected final java.util.concurrent.ConcurrentHashMap<ConsumerId,DemandSubscription> subscriptionMapByRemoteId

localBrokerPath

protected final BrokerId[] localBrokerPath

startedLatch

protected java.util.concurrent.CountDownLatch startedLatch

localStartedLatch

protected java.util.concurrent.CountDownLatch localStartedLatch

lastConnectSucceeded

protected final java.util.concurrent.atomic.AtomicBoolean lastConnectSucceeded

configuration

protected NetworkBridgeConfiguration configuration

defaultFilterFactory

protected final NetworkBridgeFilterFactory defaultFilterFactory

remoteBrokerPath

protected final BrokerId[] remoteBrokerPath

brokerInfoMutex

protected java.lang.Object brokerInfoMutex

remoteBrokerId

protected BrokerId remoteBrokerId
Constructor Detail

DemandForwardingBridgeSupport

public DemandForwardingBridgeSupport(NetworkBridgeConfiguration configuration,
                                     Transport localBroker,
                                     Transport remoteBroker)
Method Detail

duplexStart

public void duplexStart(TransportConnection connection,
                        BrokerInfo localBrokerInfo,
                        BrokerInfo remoteBrokerInfo)
                 throws java.lang.Exception
Throws:
java.lang.Exception

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

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

public void serviceRemoteException(java.lang.Throwable error)
Description copied from interface: NetworkBridge
Service an exception

Specified by:
serviceRemoteException in interface NetworkBridge

serviceRemoteCommand

protected void serviceRemoteCommand(Command command)

serviceLocalException

public void serviceLocalException(java.lang.Throwable error)
Description copied from interface: NetworkBridge
servicee an exception

Specified by:
serviceLocalException in interface NetworkBridge

getControllingService

protected Service getControllingService()

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

configureMessage

protected Message configureMessage(MessageDispatch md)

serviceLocalCommand

protected void serviceLocalCommand(Command command)

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.

getLocalBroker

public Transport getLocalBroker()
Returns:
Returns the localBroker.

getRemoteBroker

public Transport getRemoteBroker()
Returns:
Returns the remoteBroker.

isCreatedByDuplex

public boolean isCreatedByDuplex()
Returns:
the createdByDuplex

setCreatedByDuplex

public void setCreatedByDuplex(boolean createdByDuplex)
Parameters:
createdByDuplex - the createdByDuplex 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)

isPermissableDestination

protected boolean isPermissableDestination(ActiveMQDestination destination,
                                           boolean allowTemporary)

setupStaticDestinations

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


addConsumerInfo

protected boolean addConsumerInfo(ConsumerInfo consumerInfo)
                           throws java.io.IOException
Throws:
java.io.IOException

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 final 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

removeDemandSubscriptionByLocalId

protected boolean removeDemandSubscriptionByLocalId(ConsumerId consumerId)

waitStarted

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

clearDownSubscriptions

protected void clearDownSubscriptions()

createNetworkBridgeFilter

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

serviceLocalBrokerInfo

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

addRemoteBrokerToBrokerPath

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

serviceRemoteBrokerInfo

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

getRemoteBrokerPath

protected BrokerId[] getRemoteBrokerPath()

setNetworkBridgeListener

public void setNetworkBridgeListener(NetworkBridgeListener listener)
Description copied from interface: NetworkBridge
Set the NetworkBridgeFailedListener

Specified by:
setNetworkBridgeListener in interface NetworkBridge

getRemoteAddress

public java.lang.String getRemoteAddress()
Specified by:
getRemoteAddress in interface NetworkBridge

getLocalAddress

public java.lang.String getLocalAddress()
Specified by:
getLocalAddress in interface NetworkBridge

getRemoteBrokerName

public java.lang.String getRemoteBrokerName()
Specified by:
getRemoteBrokerName in interface NetworkBridge

getLocalBrokerName

public java.lang.String getLocalBrokerName()
Specified by:
getLocalBrokerName in interface NetworkBridge

getDequeueCounter

public long getDequeueCounter()
Specified by:
getDequeueCounter in interface NetworkBridge

getEnqueueCounter

public long getEnqueueCounter()
Specified by:
getEnqueueCounter in interface NetworkBridge

isDuplex

protected boolean isDuplex()

getLocalSubscriptionMap

public java.util.concurrent.ConcurrentHashMap<ConsumerId,DemandSubscription> getLocalSubscriptionMap()

setBrokerService

public void setBrokerService(BrokerService brokerService)
Specified by:
setBrokerService in interface BrokerServiceAware

setMbeanObjectName

public void setMbeanObjectName(javax.management.ObjectName objectName)
Specified by:
setMbeanObjectName in interface NetworkBridge

getMbeanObjectName

public javax.management.ObjectName getMbeanObjectName()
Specified by:
getMbeanObjectName in interface NetworkBridge


Copyright © 2005-2012. All Rights Reserved.