Class AbstractRemotingConnection
- java.lang.Object
-
- org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection
-
- All Implemented Interfaces:
RemotingConnection,BufferHandler
public abstract class AbstractRemotingConnection extends Object implements RemotingConnection
-
-
Field Summary
Fields Modifier and Type Field Description protected List<org.apache.activemq.artemis.core.remoting.CloseListener>closeListenersprotected longcreationTimeprotected booleandataReceivedprotected booleandestroyedprotected Executorexecutorprotected List<org.apache.activemq.artemis.core.remoting.FailureListener>failureListenersprotected ConnectiontransportConnection
-
Constructor Summary
Constructors Constructor Description AbstractRemotingConnection(Connection transportConnection, Executor executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCloseListener(org.apache.activemq.artemis.core.remoting.CloseListener listener)add a CloseListener.voidaddFailureListener(org.apache.activemq.artemis.core.remoting.FailureListener listener)add a failure listener.FutureasyncFail(ActiveMQException me)Same thing as fail, but using an executor.voidbufferReceived(Object connectionID, ActiveMQBuffer buffer)called by the remoting connection when a buffer is received.protected voidcallClosingListeners()protected voidcallFailureListeners(ActiveMQException me, String scaleDownTargetNodeID)booleancheckDataReceived()returns true if any data has been received since the last time this method was called.ActiveMQBuffercreateTransportBuffer(int size)creates a new ActiveMQBuffer of the specified size.voidfail(ActiveMQException me)called when the underlying connection fails.voidflush()flush all outstanding data from the connection.StringgetClientID()Returns the Client ID associated with this connectionlonggetCreationTime()Returns the creation time of theRemotingConnection.List<org.apache.activemq.artemis.core.remoting.FailureListener>getFailureListeners()return all the failure listenersObjectgetID()Returns the unique id of theRemotingConnection.StringgetLocalAddress()StringgetRemoteAddress()returns a string representation of the remote address of this connectionSubjectgetSubject()the possibly null subject associated with this connectionConnectiongetTransportConnection()return the underlying Connection.StringgetTransportLocalAddress()Returns a string representation of the local address this connection is connected to.booleanisClient()Returns whether or not theRemotingConnectionis a clientbooleanisDestroyed()Returns true if thisRemotingConnectionhas been destroyed.booleanisSupportReconnect()This will check if reconnects are supported on the protocol and configuration.booleanisSupportsFlowControl()Return true if the protocol supports flow control.booleanisWritable(ReadyListener callback)voidkillMessage(SimpleString nodeID)if slow consumer is killed,send the msessage to client.booleanremoveCloseListener(org.apache.activemq.artemis.core.remoting.CloseListener listener)remove a Close ListenerList<org.apache.activemq.artemis.core.remoting.CloseListener>removeCloseListeners()booleanremoveFailureListener(org.apache.activemq.artemis.core.remoting.FailureListener listener)remove the failure listenerList<org.apache.activemq.artemis.core.remoting.FailureListener>removeFailureListeners()voidscheduledFlush()voidsetClientID(String clientId)Sets the client ID associated with this connectionvoidsetCloseListeners(List<org.apache.activemq.artemis.core.remoting.CloseListener> listeners)voidsetFailureListeners(List<org.apache.activemq.artemis.core.remoting.FailureListener> listeners)set the failure listeners.voidsetSubject(Subject subject)sets the currently associated subject for this connection-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.artemis.spi.core.remoting.BufferHandler
endOfBatch
-
Methods inherited from interface org.apache.activemq.artemis.spi.core.protocol.RemotingConnection
destroy, disconnect, disconnect, disconnect, fail, getProtocolName, isSameTarget
-
-
-
-
Field Detail
-
failureListeners
protected final List<org.apache.activemq.artemis.core.remoting.FailureListener> failureListeners
-
closeListeners
protected final List<org.apache.activemq.artemis.core.remoting.CloseListener> closeListeners
-
transportConnection
protected final Connection transportConnection
-
executor
protected final Executor executor
-
creationTime
protected final long creationTime
-
destroyed
protected volatile boolean destroyed
-
dataReceived
protected volatile boolean dataReceived
-
-
Constructor Detail
-
AbstractRemotingConnection
public AbstractRemotingConnection(Connection transportConnection, Executor executor)
-
-
Method Detail
-
scheduledFlush
public void scheduledFlush()
- Specified by:
scheduledFlushin interfaceRemotingConnection
-
getFailureListeners
public List<org.apache.activemq.artemis.core.remoting.FailureListener> getFailureListeners()
Description copied from interface:RemotingConnectionreturn all the failure listeners- Specified by:
getFailureListenersin interfaceRemotingConnection- Returns:
- the listeners
-
isClient
public boolean isClient()
Description copied from interface:RemotingConnectionReturns whether or not theRemotingConnectionis a client- Specified by:
isClientin interfaceRemotingConnection- Returns:
- true if client, false if a server
-
isDestroyed
public boolean isDestroyed()
Description copied from interface:RemotingConnectionReturns true if thisRemotingConnectionhas been destroyed.- Specified by:
isDestroyedin interfaceRemotingConnection- Returns:
- true if destroyed, otherwise false
-
flush
public void flush()
Description copied from interface:RemotingConnectionflush all outstanding data from the connection.- Specified by:
flushin interfaceRemotingConnection
-
isWritable
public boolean isWritable(ReadyListener callback)
- Specified by:
isWritablein interfaceRemotingConnection
-
callFailureListeners
protected void callFailureListeners(ActiveMQException me, String scaleDownTargetNodeID)
-
callClosingListeners
protected void callClosingListeners()
-
setFailureListeners
public void setFailureListeners(List<org.apache.activemq.artemis.core.remoting.FailureListener> listeners)
Description copied from interface:RemotingConnectionset the failure listeners.These will be called in the event of the connection being closed. Any previously added listeners will be removed.
- Specified by:
setFailureListenersin interfaceRemotingConnection- Parameters:
listeners- the listeners to add.
-
getID
public Object getID()
Description copied from interface:RemotingConnectionReturns the unique id of theRemotingConnection.- Specified by:
getIDin interfaceRemotingConnection- Returns:
- the id
-
getLocalAddress
public String getLocalAddress()
-
getRemoteAddress
public String getRemoteAddress()
Description copied from interface:RemotingConnectionreturns a string representation of the remote address of this connection- Specified by:
getRemoteAddressin interfaceRemotingConnection- Returns:
- the remote address
-
addFailureListener
public void addFailureListener(org.apache.activemq.artemis.core.remoting.FailureListener listener)
Description copied from interface:RemotingConnectionadd a failure listener.The listener will be called in the event of connection failure.
- Specified by:
addFailureListenerin interfaceRemotingConnection- Parameters:
listener- the listener
-
removeFailureListener
public boolean removeFailureListener(org.apache.activemq.artemis.core.remoting.FailureListener listener)
Description copied from interface:RemotingConnectionremove the failure listener- Specified by:
removeFailureListenerin interfaceRemotingConnection- Parameters:
listener- the lister to remove- Returns:
- true if removed
-
addCloseListener
public void addCloseListener(org.apache.activemq.artemis.core.remoting.CloseListener listener)
Description copied from interface:RemotingConnectionadd a CloseListener.This will be called in the event of the connection being closed.
- Specified by:
addCloseListenerin interfaceRemotingConnection- Parameters:
listener- the listener to add
-
removeCloseListener
public boolean removeCloseListener(org.apache.activemq.artemis.core.remoting.CloseListener listener)
Description copied from interface:RemotingConnectionremove a Close Listener- Specified by:
removeCloseListenerin interfaceRemotingConnection- Parameters:
listener- the listener to remove- Returns:
- true if removed
-
removeCloseListeners
public List<org.apache.activemq.artemis.core.remoting.CloseListener> removeCloseListeners()
- Specified by:
removeCloseListenersin interfaceRemotingConnection
-
removeFailureListeners
public List<org.apache.activemq.artemis.core.remoting.FailureListener> removeFailureListeners()
- Specified by:
removeFailureListenersin interfaceRemotingConnection
-
setCloseListeners
public void setCloseListeners(List<org.apache.activemq.artemis.core.remoting.CloseListener> listeners)
- Specified by:
setCloseListenersin interfaceRemotingConnection
-
createTransportBuffer
public ActiveMQBuffer createTransportBuffer(int size)
Description copied from interface:RemotingConnectioncreates a new ActiveMQBuffer of the specified size. For the purpose of i/o outgoing packets- Specified by:
createTransportBufferin interfaceRemotingConnection- Parameters:
size- the size of buffer required- Returns:
- the buffer
-
getTransportConnection
public Connection getTransportConnection()
Description copied from interface:RemotingConnectionreturn the underlying Connection.- Specified by:
getTransportConnectionin interfaceRemotingConnection- Returns:
- the connection
-
getCreationTime
public long getCreationTime()
Description copied from interface:RemotingConnectionReturns the creation time of theRemotingConnection.- Specified by:
getCreationTimein interfaceRemotingConnection
-
checkDataReceived
public boolean checkDataReceived()
Description copied from interface:RemotingConnectionreturns true if any data has been received since the last time this method was called.- Specified by:
checkDataReceivedin interfaceRemotingConnection- Returns:
- true if data has been received.
-
fail
public void fail(ActiveMQException me)
Description copied from interface:RemotingConnectioncalled when the underlying connection fails.- Specified by:
failin interfaceRemotingConnection- Parameters:
me- the exception that caused the failure
-
asyncFail
public Future asyncFail(ActiveMQException me)
Description copied from interface:RemotingConnectionSame thing as fail, but using an executor. semantic of send here, is asynchrounous.- Specified by:
asyncFailin interfaceRemotingConnection
-
bufferReceived
public void bufferReceived(Object connectionID, ActiveMQBuffer buffer)
Description copied from interface:BufferHandlercalled by the remoting connection when a buffer is received.- Specified by:
bufferReceivedin interfaceBufferHandler- Parameters:
connectionID- the connection the buffer was received onbuffer- the buffer to decode
-
killMessage
public void killMessage(SimpleString nodeID)
Description copied from interface:RemotingConnectionif slow consumer is killed,send the msessage to client.- Specified by:
killMessagein interfaceRemotingConnection
-
isSupportReconnect
public boolean isSupportReconnect()
Description copied from interface:RemotingConnectionThis will check if reconnects are supported on the protocol and configuration. In case it's not supported a connection failure could remove messages right away from pending deliveries.- Specified by:
isSupportReconnectin interfaceRemotingConnection- Returns:
-
isSupportsFlowControl
public boolean isSupportsFlowControl()
Description copied from interface:RemotingConnectionReturn true if the protocol supports flow control. This is because in some cases we may need to hold message producers in cases like disk full. If the protocol doesn't support it we trash the connection and throw exceptions.- Specified by:
isSupportsFlowControlin interfaceRemotingConnection- Returns:
-
setSubject
public void setSubject(Subject subject)
Description copied from interface:RemotingConnectionsets the currently associated subject for this connection- Specified by:
setSubjectin interfaceRemotingConnection
-
getSubject
public Subject getSubject()
Description copied from interface:RemotingConnectionthe possibly null subject associated with this connection- Specified by:
getSubjectin interfaceRemotingConnection- Returns:
-
setClientID
public void setClientID(String clientId)
Description copied from interface:RemotingConnectionSets the client ID associated with this connection- Specified by:
setClientIDin interfaceRemotingConnection
-
getClientID
public String getClientID()
Description copied from interface:RemotingConnectionReturns the Client ID associated with this connection- Specified by:
getClientIDin interfaceRemotingConnection- Returns:
-
getTransportLocalAddress
public String getTransportLocalAddress()
Description copied from interface:RemotingConnectionReturns a string representation of the local address this connection is connected to. This is useful when the server is configured at 0.0.0.0 (or multiple IPs). This will give you the actual IP that's being used.- Specified by:
getTransportLocalAddressin interfaceRemotingConnection- Returns:
- the local address of transport connection
-
-