Package org.apache.activemq.state
Class ConnectionStateTracker
- java.lang.Object
-
- org.apache.activemq.state.CommandVisitorAdapter
-
- org.apache.activemq.state.ConnectionStateTracker
-
- All Implemented Interfaces:
CommandVisitor
public class ConnectionStateTracker extends CommandVisitorAdapter
Tracks the state of a connection so a newly established transport can be re-initialized to the state that was tracked.
-
-
Field Summary
Fields Modifier and Type Field Description protected ConcurrentMap<ConnectionId,ConnectionState>
connectionStates
-
Constructor Summary
Constructors Constructor Description ConnectionStateTracker()
-
Method Summary
-
Methods inherited from class org.apache.activemq.state.CommandVisitorAdapter
processBrokerInfo, processBrokerSubscriptionInfo, processConnectionControl, processConnectionError, processConsumerControl, processControlCommand, processFlush, processForgetTransaction, processKeepAlive, processMessageAck, processMessageDispatch, processMessageDispatchNotification, processProducerAck, processRecoverTransactions, processRemoveSubscription, processShutdown, processWireFormat
-
-
-
-
Field Detail
-
connectionStates
protected final ConcurrentMap<ConnectionId,ConnectionState> connectionStates
-
-
Method Detail
-
track
public Tracked track(Command command) throws IOException
Entry point for all tracked commands in the tracker. Commands should be tracked before there is an attempt to send them on the wire. Upon a successful send of a command it is necessary to call the trackBack method to complete the tracking of the given command.- Parameters:
command
- The command that is to be tracked by this tracker.- Returns:
- null if the command is not state tracked.
- Throws:
IOException
- if an error occurs during setup of the tracking operation.
-
trackBack
public void trackBack(Command command)
Completes the two phase tracking operation for a command that is sent on the wire. Once the command is sent successfully to complete the tracking operation or otherwise update the state of the tracker.- Parameters:
command
- The command that was previously provided to the track method.
-
restore
public void restore(Transport transport) throws IOException
- Throws:
IOException
-
restoreSessions
protected void restoreSessions(Transport transport, ConnectionState connectionState) throws IOException
- Parameters:
transport
-connectionState
-- Throws:
IOException
-
restoreConsumers
protected void restoreConsumers(Transport transport, SessionState sessionState) throws IOException
- Parameters:
transport
-sessionState
-- Throws:
IOException
-
restoreProducers
protected void restoreProducers(Transport transport, SessionState sessionState) throws IOException
- Parameters:
transport
-sessionState
-- Throws:
IOException
-
restoreTempDestinations
protected void restoreTempDestinations(Transport transport, ConnectionState connectionState) throws IOException
- Parameters:
transport
-connectionState
-- Throws:
IOException
-
processAddDestination
public Response processAddDestination(DestinationInfo info)
- Specified by:
processAddDestination
in interfaceCommandVisitor
- Overrides:
processAddDestination
in classCommandVisitorAdapter
-
processRemoveDestination
public Response processRemoveDestination(DestinationInfo info)
- Specified by:
processRemoveDestination
in interfaceCommandVisitor
- Overrides:
processRemoveDestination
in classCommandVisitorAdapter
-
processAddProducer
public Response processAddProducer(ProducerInfo info)
- Specified by:
processAddProducer
in interfaceCommandVisitor
- Overrides:
processAddProducer
in classCommandVisitorAdapter
-
processRemoveProducer
public Response processRemoveProducer(ProducerId id)
- Specified by:
processRemoveProducer
in interfaceCommandVisitor
- Overrides:
processRemoveProducer
in classCommandVisitorAdapter
-
processAddConsumer
public Response processAddConsumer(ConsumerInfo info)
- Specified by:
processAddConsumer
in interfaceCommandVisitor
- Overrides:
processAddConsumer
in classCommandVisitorAdapter
-
processRemoveConsumer
public Response processRemoveConsumer(ConsumerId id, long lastDeliveredSequenceId)
- Specified by:
processRemoveConsumer
in interfaceCommandVisitor
- Overrides:
processRemoveConsumer
in classCommandVisitorAdapter
-
processAddSession
public Response processAddSession(SessionInfo info)
- Specified by:
processAddSession
in interfaceCommandVisitor
- Overrides:
processAddSession
in classCommandVisitorAdapter
-
processRemoveSession
public Response processRemoveSession(SessionId id, long lastDeliveredSequenceId)
- Specified by:
processRemoveSession
in interfaceCommandVisitor
- Overrides:
processRemoveSession
in classCommandVisitorAdapter
-
processAddConnection
public Response processAddConnection(ConnectionInfo info)
- Specified by:
processAddConnection
in interfaceCommandVisitor
- Overrides:
processAddConnection
in classCommandVisitorAdapter
-
processRemoveConnection
public Response processRemoveConnection(ConnectionId id, long lastDeliveredSequenceId) throws Exception
- Specified by:
processRemoveConnection
in interfaceCommandVisitor
- Overrides:
processRemoveConnection
in classCommandVisitorAdapter
- Throws:
Exception
-
processMessage
public Response processMessage(Message send) throws Exception
- Specified by:
processMessage
in interfaceCommandVisitor
- Overrides:
processMessage
in classCommandVisitorAdapter
- Throws:
Exception
-
processBeginTransaction
public Response processBeginTransaction(TransactionInfo info)
- Specified by:
processBeginTransaction
in interfaceCommandVisitor
- Overrides:
processBeginTransaction
in classCommandVisitorAdapter
-
processPrepareTransaction
public Response processPrepareTransaction(TransactionInfo info) throws Exception
- Specified by:
processPrepareTransaction
in interfaceCommandVisitor
- Overrides:
processPrepareTransaction
in classCommandVisitorAdapter
- Throws:
Exception
-
processCommitTransactionOnePhase
public Response processCommitTransactionOnePhase(TransactionInfo info) throws Exception
- Specified by:
processCommitTransactionOnePhase
in interfaceCommandVisitor
- Overrides:
processCommitTransactionOnePhase
in classCommandVisitorAdapter
- Throws:
Exception
-
processCommitTransactionTwoPhase
public Response processCommitTransactionTwoPhase(TransactionInfo info) throws Exception
- Specified by:
processCommitTransactionTwoPhase
in interfaceCommandVisitor
- Overrides:
processCommitTransactionTwoPhase
in classCommandVisitorAdapter
- Throws:
Exception
-
processRollbackTransaction
public Response processRollbackTransaction(TransactionInfo info) throws Exception
- Specified by:
processRollbackTransaction
in interfaceCommandVisitor
- Overrides:
processRollbackTransaction
in classCommandVisitorAdapter
- Throws:
Exception
-
processEndTransaction
public Response processEndTransaction(TransactionInfo info) throws Exception
- Specified by:
processEndTransaction
in interfaceCommandVisitor
- Overrides:
processEndTransaction
in classCommandVisitorAdapter
- Throws:
Exception
-
processMessagePull
public Response processMessagePull(MessagePull pull) throws Exception
- Specified by:
processMessagePull
in interfaceCommandVisitor
- Overrides:
processMessagePull
in classCommandVisitorAdapter
- Throws:
Exception
-
isRestoreConsumers
public boolean isRestoreConsumers()
-
setRestoreConsumers
public void setRestoreConsumers(boolean restoreConsumers)
-
isRestoreProducers
public boolean isRestoreProducers()
-
setRestoreProducers
public void setRestoreProducers(boolean restoreProducers)
-
isRestoreSessions
public boolean isRestoreSessions()
-
setRestoreSessions
public void setRestoreSessions(boolean restoreSessions)
-
isTrackTransactions
public boolean isTrackTransactions()
-
setTrackTransactions
public void setTrackTransactions(boolean trackTransactions)
-
isTrackTransactionProducers
public boolean isTrackTransactionProducers()
-
setTrackTransactionProducers
public void setTrackTransactionProducers(boolean trackTransactionProducers)
-
isRestoreTransaction
public boolean isRestoreTransaction()
-
setRestoreTransaction
public void setRestoreTransaction(boolean restoreTransaction)
-
isTrackMessages
public boolean isTrackMessages()
-
setTrackMessages
public void setTrackMessages(boolean trackMessages)
-
getMaxCacheSize
public int getMaxCacheSize()
-
setMaxCacheSize
public void setMaxCacheSize(int maxCacheSize)
-
getCurrentCacheSize
public long getCurrentCacheSize()
- Returns:
- the current cache size for the Message and MessagePull Command cache.
-
connectionInterruptProcessingComplete
public void connectionInterruptProcessingComplete(Transport transport, ConnectionId connectionId)
-
transportInterrupted
public void transportInterrupted(ConnectionId connectionId)
-
-