Package org.apache.activemq.network
Class DemandForwardingBridgeSupport
- java.lang.Object
-
- org.apache.activemq.network.DemandForwardingBridgeSupport
-
- All Implemented Interfaces:
BrokerServiceAware
,NetworkBridge
,Service
- Direct Known Subclasses:
CompositeDemandForwardingBridge
,DemandForwardingBridge
public abstract class DemandForwardingBridgeSupport extends Object implements NetworkBridge, BrokerServiceAware
A useful base class for implementing demand forwarding bridges.
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DemandForwardingBridgeSupport(NetworkBridgeConfiguration configuration, Transport localBroker, Transport remoteBroker)
-
Method Summary
-
-
-
Field Detail
-
DURABLE_SUB_PREFIX
protected static final String DURABLE_SUB_PREFIX
- See Also:
- Constant Field Values
-
localBroker
protected final Transport localBroker
-
remoteBroker
protected final Transport remoteBroker
-
idGenerator
protected 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 String remoteBrokerName
-
localClientId
protected String localClientId
-
demandConsumerInfo
protected ConsumerInfo demandConsumerInfo
-
demandConsumerDispatched
protected int demandConsumerDispatched
-
localBridgeStarted
protected final AtomicBoolean localBridgeStarted
-
remoteBridgeStarted
protected final AtomicBoolean remoteBridgeStarted
-
bridgeFailed
protected final AtomicBoolean bridgeFailed
-
disposed
protected final 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 ConcurrentMap<ConsumerId,DemandSubscription> subscriptionMapByLocalId
-
subscriptionMapByRemoteId
protected final ConcurrentMap<ConsumerId,DemandSubscription> subscriptionMapByRemoteId
-
forcedDurableRemoteId
protected final Set<ConsumerId> forcedDurableRemoteId
-
localBrokerPath
protected final BrokerId[] localBrokerPath
-
startedLatch
protected final CountDownLatch startedLatch
-
localStartedLatch
protected final CountDownLatch localStartedLatch
-
staticDestinationsLatch
protected final CountDownLatch staticDestinationsLatch
-
lastConnectSucceeded
protected final AtomicBoolean lastConnectSucceeded
-
configuration
protected NetworkBridgeConfiguration configuration
-
defaultFilterFactory
protected final NetworkBridgeFilterFactory defaultFilterFactory
-
remoteBrokerPath
protected final BrokerId[] remoteBrokerPath
-
remoteBrokerId
protected BrokerId remoteBrokerId
-
networkBridgeStatistics
protected final NetworkBridgeStatistics networkBridgeStatistics
-
brokerService
protected BrokerService brokerService
-
-
Constructor Detail
-
DemandForwardingBridgeSupport
public DemandForwardingBridgeSupport(NetworkBridgeConfiguration configuration, Transport localBroker, Transport remoteBroker)
-
-
Method Detail
-
duplexStart
public void duplexStart(TransportConnection connection, BrokerInfo localBrokerInfo, BrokerInfo remoteBrokerInfo) throws Exception
- Throws:
Exception
-
start
public void start() throws Exception
-
triggerStartAsyncNetworkBridgeCreation
protected void triggerStartAsyncNetworkBridgeCreation() throws IOException
- Throws:
IOException
-
serviceRemoteException
public void serviceRemoteException(Throwable error)
Description copied from interface:NetworkBridge
Service an exception received from the Remote Broker connection.- Specified by:
serviceRemoteException
in interfaceNetworkBridge
-
isDirectBridgeConsumer
protected boolean isDirectBridgeConsumer(ConsumerInfo info)
Checks whether or not this consumer is a direct bridge network subscription- Parameters:
info
-- Returns:
-
isProxyBridgeSubscription
protected boolean isProxyBridgeSubscription(String clientId, String subName)
-
addProxyNetworkSubscriptionClientId
protected void addProxyNetworkSubscriptionClientId(DemandSubscription sub, String clientId, String subName)
This scenaior is primarily used for durable sync on broker restarts- Parameters:
sub
-clientId
-subName
-
-
addProxyNetworkSubscriptionBrokerPath
protected void addProxyNetworkSubscriptionBrokerPath(DemandSubscription sub, BrokerId[] path, String subName)
Add a durable remote proxy subscription when we can generate via the BrokerId path This is the most common scenario- Parameters:
sub
-path
-subName
-
-
isProxyNSConsumerBrokerPath
protected boolean isProxyNSConsumerBrokerPath(ConsumerInfo info)
-
isProxyNSConsumerClientId
protected boolean isProxyNSConsumerClientId(String clientId)
-
serviceRemoteCommand
protected void serviceRemoteCommand(Command command)
-
serviceLocalException
public void serviceLocalException(Throwable error)
Description copied from interface:NetworkBridge
Service an exception received from the Local Broker connection.- Specified by:
serviceLocalException
in interfaceNetworkBridge
-
serviceLocalException
public void serviceLocalException(MessageDispatch messageDispatch, Throwable error)
-
getControllingService
protected Service getControllingService()
-
addSubscription
protected void addSubscription(DemandSubscription sub) throws IOException
- Throws:
IOException
-
removeSubscription
protected void removeSubscription(DemandSubscription sub) throws IOException
- Throws:
IOException
-
configureMessage
protected Message configureMessage(MessageDispatch md) throws IOException
- Throws:
IOException
-
serviceLocalCommand
protected void serviceLocalCommand(Command command)
-
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 void addConsumerInfo(ConsumerInfo consumerInfo) throws IOException
- Throws:
IOException
-
getRegionSubscriptions
protected final Collection<Subscription> getRegionSubscriptions(ActiveMQDestination dest)
-
createDemandSubscription
protected DemandSubscription createDemandSubscription(ConsumerInfo info) throws IOException
- Throws:
IOException
-
doCreateDemandSubscription
protected DemandSubscription doCreateDemandSubscription(ConsumerInfo info) throws IOException
- Throws:
IOException
-
createDemandSubscription
protected final DemandSubscription createDemandSubscription(ActiveMQDestination destination, String subscriptionName)
-
configureDemandSubscription
protected void configureDemandSubscription(ConsumerInfo info, DemandSubscription sub) throws IOException
- Throws:
IOException
-
removeDemandSubscription
protected void removeDemandSubscription(ConsumerId id) throws IOException
- Throws:
IOException
-
removeDemandSubscriptionByLocalId
protected boolean removeDemandSubscriptionByLocalId(ConsumerId consumerId)
-
safeWaitUntilStarted
protected boolean safeWaitUntilStarted() throws InterruptedException
Performs a timed wait on the started latch and then checks for disposed before performing another wait each time the the started wait times out.- Throws:
InterruptedException
-
createNetworkBridgeFilter
protected NetworkBridgeFilter createNetworkBridgeFilter(ConsumerInfo info) throws IOException
- Throws:
IOException
-
addRemoteBrokerToBrokerPath
protected void addRemoteBrokerToBrokerPath(ConsumerInfo info) throws IOException
- Throws:
IOException
-
getRemoteBrokerPath
protected BrokerId[] getRemoteBrokerPath()
-
setNetworkBridgeListener
public void setNetworkBridgeListener(NetworkBridgeListener listener)
Description copied from interface:NetworkBridge
Set the NetworkBridgeFailedListener- Specified by:
setNetworkBridgeListener
in interfaceNetworkBridge
-
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
-
getRemoteAddress
public String getRemoteAddress()
- Specified by:
getRemoteAddress
in interfaceNetworkBridge
- Returns:
- the network address of the remote broker connection.
-
getLocalAddress
public String getLocalAddress()
- Specified by:
getLocalAddress
in interfaceNetworkBridge
- Returns:
- the network address of the local broker connection.
-
getRemoteBrokerName
public String getRemoteBrokerName()
- Specified by:
getRemoteBrokerName
in interfaceNetworkBridge
- Returns:
- the name of the remote broker this bridge is connected to.
-
getRemoteBrokerId
public String getRemoteBrokerId()
- Specified by:
getRemoteBrokerId
in interfaceNetworkBridge
- Returns:
- the id of the remote broker this bridge is connected to.
-
getLocalBrokerName
public String getLocalBrokerName()
- Specified by:
getLocalBrokerName
in interfaceNetworkBridge
- Returns:
- the name of the local broker this bridge is connected to.
-
getDequeueCounter
public long getDequeueCounter()
- Specified by:
getDequeueCounter
in interfaceNetworkBridge
- Returns:
- the current number of dequeues this bridge has.
-
getEnqueueCounter
public long getEnqueueCounter()
- Specified by:
getEnqueueCounter
in interfaceNetworkBridge
- Returns:
- the current number of enqueues this bridge has.
-
getNetworkBridgeStatistics
public NetworkBridgeStatistics getNetworkBridgeStatistics()
- Specified by:
getNetworkBridgeStatistics
in interfaceNetworkBridge
- Returns:
- the statistics for this NetworkBridge
-
isDuplex
protected boolean isDuplex()
-
getLocalSubscriptionMap
public ConcurrentMap<ConsumerId,DemandSubscription> getLocalSubscriptionMap()
-
setBrokerService
public void setBrokerService(BrokerService brokerService)
- Specified by:
setBrokerService
in interfaceBrokerServiceAware
-
setMbeanObjectName
public void setMbeanObjectName(ObjectName objectName)
- Specified by:
setMbeanObjectName
in interfaceNetworkBridge
- Parameters:
objectName
- The ObjectName assigned to this bridge in the MBean server.
-
getMbeanObjectName
public ObjectName getMbeanObjectName()
- Specified by:
getMbeanObjectName
in interfaceNetworkBridge
- Returns:
- the MBean name used to identify this bridge in the MBean server.
-
resetStats
public void resetStats()
- Specified by:
resetStats
in interfaceNetworkBridge
-
serviceOutbound
protected void serviceOutbound(Message message)
-
serviceInboundMessage
protected void serviceInboundMessage(Message message)
-
canDuplexDispatch
protected boolean canDuplexDispatch(Message message)
-
getStoredSequenceIdForMessage
protected long getStoredSequenceIdForMessage(MessageId messageId)
-
configureConsumerPrefetch
protected void configureConsumerPrefetch(ConsumerInfo consumerInfo)
-
-