org.apache.activemq.broker
Class TransportConnection
java.lang.Object
org.apache.activemq.broker.TransportConnection
- All Implemented Interfaces:
- Connection, Service, CommandVisitor, Task
- Direct Known Subclasses:
- ManagedTransportConnection
public class TransportConnection
- extends java.lang.Object
- implements Service, Connection, Task, CommandVisitor
- Version:
- $Revision: 1.8 $
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
broker
protected final Broker broker
connector
protected final TransportConnector connector
localConnectionStates
protected final edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap localConnectionStates
brokerConnectionStates
protected final java.util.Map brokerConnectionStates
brokerInfo
protected BrokerInfo brokerInfo
dispatchQueue
protected final java.util.List dispatchQueue
taskRunner
protected final TaskRunner taskRunner
transportException
protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicReference transportException
disposed
protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposed
asyncException
protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean asyncException
dispatchStopped
protected edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean dispatchStopped
TransportConnection
public TransportConnection(TransportConnector connector,
Transport transport,
Broker broker,
TaskRunnerFactory taskRunnerFactory)
- Parameters:
connector
- transport
- broker
- taskRunnerFactory
- - can be null if you want direct dispatch to the transport else commands are sent async.
getDispatchQueueSize
public int getDispatchQueueSize()
- Returns the number of messages to be dispatched to this connection
- Specified by:
getDispatchQueueSize
in interface Connection
serviceTransportException
public void serviceTransportException(java.io.IOException e)
serviceExceptionAsync
public void serviceExceptionAsync(java.io.IOException e)
- Calls the serviceException method in an async thread. Since
handling a service exception closes a socket, we should not tie
up broker threads since client sockets may hang or cause deadlocks.
- Specified by:
serviceExceptionAsync
in interface Connection
- Parameters:
e
-
serviceException
public void serviceException(java.lang.Throwable e)
- Closes a clients connection due to a detected error.
Errors are ignored if: the client is closing or broker is closing.
Otherwise, the connection error transmitted to the client before stopping it's
transport.
- Specified by:
serviceException
in interface Connection
service
public Response service(Command command)
- Description copied from interface:
Connection
- Services a client command and submits it to the broker.
- Specified by:
service
in interface Connection
lookupConnectionState
protected org.apache.activemq.broker.TransportConnection.ConnectionState lookupConnectionState(ConsumerId id)
lookupConnectionState
protected org.apache.activemq.broker.TransportConnection.ConnectionState lookupConnectionState(ProducerId id)
lookupConnectionState
protected org.apache.activemq.broker.TransportConnection.ConnectionState lookupConnectionState(SessionId id)
lookupConnectionState
protected org.apache.activemq.broker.TransportConnection.ConnectionState lookupConnectionState(ConnectionId connectionId)
processKeepAlive
public Response processKeepAlive(KeepAliveInfo info)
throws java.lang.Exception
- Specified by:
processKeepAlive
in interface CommandVisitor
- Throws:
java.lang.Exception
processRemoveSubscription
public Response processRemoveSubscription(RemoveSubscriptionInfo info)
throws java.lang.Exception
- Specified by:
processRemoveSubscription
in interface CommandVisitor
- Throws:
java.lang.Exception
processWireFormat
public Response processWireFormat(WireFormatInfo info)
throws java.lang.Exception
- Specified by:
processWireFormat
in interface CommandVisitor
- Throws:
java.lang.Exception
processShutdown
public Response processShutdown(ShutdownInfo info)
throws java.lang.Exception
- Specified by:
processShutdown
in interface CommandVisitor
- Throws:
java.lang.Exception
processFlush
public Response processFlush(FlushCommand command)
throws java.lang.Exception
- Specified by:
processFlush
in interface CommandVisitor
- Throws:
java.lang.Exception
processBeginTransaction
public Response processBeginTransaction(TransactionInfo info)
throws java.lang.Exception
- Specified by:
processBeginTransaction
in interface CommandVisitor
- Throws:
java.lang.Exception
processEndTransaction
public Response processEndTransaction(TransactionInfo info)
throws java.lang.Exception
- Specified by:
processEndTransaction
in interface CommandVisitor
- Throws:
java.lang.Exception
processPrepareTransaction
public Response processPrepareTransaction(TransactionInfo info)
throws java.lang.Exception
- Specified by:
processPrepareTransaction
in interface CommandVisitor
- Throws:
java.lang.Exception
processCommitTransactionOnePhase
public Response processCommitTransactionOnePhase(TransactionInfo info)
throws java.lang.Exception
- Specified by:
processCommitTransactionOnePhase
in interface CommandVisitor
- Throws:
java.lang.Exception
processCommitTransactionTwoPhase
public Response processCommitTransactionTwoPhase(TransactionInfo info)
throws java.lang.Exception
- Specified by:
processCommitTransactionTwoPhase
in interface CommandVisitor
- Throws:
java.lang.Exception
processRollbackTransaction
public Response processRollbackTransaction(TransactionInfo info)
throws java.lang.Exception
- Specified by:
processRollbackTransaction
in interface CommandVisitor
- Throws:
java.lang.Exception
processForgetTransaction
public Response processForgetTransaction(TransactionInfo info)
throws java.lang.Exception
- Specified by:
processForgetTransaction
in interface CommandVisitor
- Throws:
java.lang.Exception
processRecoverTransactions
public Response processRecoverTransactions(TransactionInfo info)
throws java.lang.Exception
- Specified by:
processRecoverTransactions
in interface CommandVisitor
- Throws:
java.lang.Exception
processMessage
public Response processMessage(Message messageSend)
throws java.lang.Exception
- Specified by:
processMessage
in interface CommandVisitor
- Throws:
java.lang.Exception
processMessageAck
public Response processMessageAck(MessageAck ack)
throws java.lang.Exception
- Specified by:
processMessageAck
in interface CommandVisitor
- Throws:
java.lang.Exception
processMessagePull
public Response processMessagePull(MessagePull pull)
throws java.lang.Exception
- Specified by:
processMessagePull
in interface CommandVisitor
- Throws:
java.lang.Exception
processMessageDispatchNotification
public Response processMessageDispatchNotification(MessageDispatchNotification notification)
throws java.lang.Exception
- Specified by:
processMessageDispatchNotification
in interface CommandVisitor
- Throws:
java.lang.Exception
processAddDestination
public Response processAddDestination(DestinationInfo info)
throws java.lang.Exception
- Specified by:
processAddDestination
in interface CommandVisitor
- Throws:
java.lang.Exception
processRemoveDestination
public Response processRemoveDestination(DestinationInfo info)
throws java.lang.Exception
- Specified by:
processRemoveDestination
in interface CommandVisitor
- Throws:
java.lang.Exception
processAddProducer
public Response processAddProducer(ProducerInfo info)
throws java.lang.Exception
- Specified by:
processAddProducer
in interface CommandVisitor
- Throws:
java.lang.Exception
processRemoveProducer
public Response processRemoveProducer(ProducerId id)
throws java.lang.Exception
- Specified by:
processRemoveProducer
in interface CommandVisitor
- Throws:
java.lang.Exception
processAddConsumer
public Response processAddConsumer(ConsumerInfo info)
throws java.lang.Exception
- Specified by:
processAddConsumer
in interface CommandVisitor
- Throws:
java.lang.Exception
processRemoveConsumer
public Response processRemoveConsumer(ConsumerId id)
throws java.lang.Exception
- Specified by:
processRemoveConsumer
in interface CommandVisitor
- Throws:
java.lang.Exception
processAddSession
public Response processAddSession(SessionInfo info)
throws java.lang.Exception
- Specified by:
processAddSession
in interface CommandVisitor
- Throws:
java.lang.Exception
processRemoveSession
public Response processRemoveSession(SessionId id)
throws java.lang.Exception
- Specified by:
processRemoveSession
in interface CommandVisitor
- Throws:
java.lang.Exception
processAddConnection
public Response processAddConnection(ConnectionInfo info)
throws java.lang.Exception
- Specified by:
processAddConnection
in interface CommandVisitor
- Throws:
java.lang.Exception
processRemoveConnection
public Response processRemoveConnection(ConnectionId id)
- Specified by:
processRemoveConnection
in interface CommandVisitor
getConnector
public Connector getConnector()
- Specified by:
getConnector
in interface Connection
- Returns:
- the connector that created this connection.
dispatchSync
public void dispatchSync(Command message)
- Description copied from interface:
Connection
- Sends a message to the client.
- Specified by:
dispatchSync
in interface Connection
- Parameters:
message
- the message to send to the client.
dispatchAsync
public void dispatchAsync(Command message)
- Description copied from interface:
Connection
- Sends a message to the client.
- Specified by:
dispatchAsync
in interface Connection
processDispatch
protected void processDispatch(Command command)
throws java.io.IOException
- Throws:
java.io.IOException
iterate
public boolean iterate()
- Specified by:
iterate
in interface Task
getStatistics
public ConnectionStatistics getStatistics()
- Returns the statistics for this connection
- Specified by:
getStatistics
in interface Connection
getMessageAuthorizationPolicy
public MessageAuthorizationPolicy getMessageAuthorizationPolicy()
setMessageAuthorizationPolicy
public void setMessageAuthorizationPolicy(MessageAuthorizationPolicy messageAuthorizationPolicy)
isManageable
public boolean isManageable()
- Specified by:
isManageable
in interface Connection
- Returns:
- true if the Connection will process control commands
start
public void start()
throws java.lang.Exception
- Specified by:
start
in interface Service
- Throws:
java.lang.Exception
stop
public void stop()
throws java.lang.Exception
- Specified by:
stop
in interface Service
- Throws:
java.lang.Exception
isBlockedCandidate
public boolean isBlockedCandidate()
- Returns:
- Returns the blockedCandidate.
setBlockedCandidate
public void setBlockedCandidate(boolean blockedCandidate)
- Parameters:
blockedCandidate
- The blockedCandidate to set.
isMarkedCandidate
public boolean isMarkedCandidate()
- Returns:
- Returns the markedCandidate.
setMarkedCandidate
public void setMarkedCandidate(boolean markedCandidate)
- Parameters:
markedCandidate
- The markedCandidate to set.
setSlow
public void setSlow(boolean slow)
- Parameters:
slow
- The slow to set.
isSlow
public boolean isSlow()
- Specified by:
isSlow
in interface Connection
- Returns:
- true if the Connection is slow
isMarkedBlockedCandidate
public boolean isMarkedBlockedCandidate()
- Returns:
- true if the Connection is potentially blocked
doMark
public void doMark()
- Mark the Connection, so we can deem if it's collectable on the next sweep
isBlocked
public boolean isBlocked()
- Specified by:
isBlocked
in interface Connection
- Returns:
- if after being marked, the Connection is still writing
isConnected
public boolean isConnected()
- Specified by:
isConnected
in interface Connection
- Returns:
- true if the Connection is connected
setBlocked
public void setBlocked(boolean blocked)
- Parameters:
blocked
- The blocked to set.
setConnected
public void setConnected(boolean connected)
- Parameters:
connected
- The connected to set.
isActive
public boolean isActive()
- Specified by:
isActive
in interface Connection
- Returns:
- true if the Connection is active
setActive
public void setActive(boolean active)
- Parameters:
active
- The active to set.
isStarting
public boolean isStarting()
- Returns:
- true if the Connection is starting
setStarting
protected void setStarting(boolean starting)
isPendingStop
public boolean isPendingStop()
- Returns:
- true if the Connection needs to stop
setPendingStop
protected void setPendingStop(boolean pendingStop)
processBrokerInfo
public Response processBrokerInfo(BrokerInfo info)
- Specified by:
processBrokerInfo
in interface CommandVisitor
dispatch
protected void dispatch(Command command)
throws java.io.IOException
- Throws:
java.io.IOException
getRemoteAddress
public java.lang.String getRemoteAddress()
- Specified by:
getRemoteAddress
in interface Connection
- Returns:
- the source address for this connection
getConnectionId
public java.lang.String getConnectionId()
- Specified by:
getConnectionId
in interface Connection
disposeTransport
protected void disposeTransport()
Copyright © 2009 Apache Software Foundation. All Rights Reserved.