Class AbstractRemotingConnection
java.lang.Object
org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection
- All Implemented Interfaces:
RemotingConnection
,BufferHandler
-
Field Summary
Modifier and TypeFieldDescriptionprotected final List<org.apache.activemq.artemis.core.remoting.CloseListener>
protected final long
protected boolean
protected boolean
protected final Executor
protected final List<org.apache.activemq.artemis.core.remoting.FailureListener>
protected final Connection
-
Constructor Summary
ConstructorDescriptionAbstractRemotingConnection
(Connection transportConnection, Executor executor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCloseListener
(org.apache.activemq.artemis.core.remoting.CloseListener listener) add a CloseListener.void
addFailureListener
(org.apache.activemq.artemis.core.remoting.FailureListener listener) add a failure listener.Same thing as fail, but using an executor.void
bufferReceived
(Object connectionID, ActiveMQBuffer buffer) called by the remoting connection when a buffer is received.protected void
protected void
callFailureListeners
(ActiveMQException me, String scaleDownTargetNodeID) boolean
returns true if any data has been received since the last time this method was called.void
close()
createTransportBuffer
(int size) creates a new ActiveMQBuffer of the specified size.void
called when the underlying connection fails.void
flush()
flush all outstanding data from the connection.Returns the Client ID associated with this connectionlong
Returns the creation time of theRemotingConnection
.List<org.apache.activemq.artemis.core.remoting.FailureListener>
return all the failure listenersgetID()
Returns the unique id of theRemotingConnection
.returns a string representation of the remote address of this connectionthe possibly null subject associated with this connectionreturn the underlying Connection.Returns a string representation of the local address this connection is connected to.boolean
isClient()
Returns whether or not theRemotingConnection
is a clientboolean
Returns true if thisRemotingConnection
has been destroyed.boolean
This will check if reconnects are supported on the protocol and configuration.boolean
Return true if the protocol supports flow control.boolean
isWritable
(ReadyListener callback) void
killMessage
(SimpleString nodeID) if slow consumer is killed,send the msessage to client.boolean
removeCloseListener
(org.apache.activemq.artemis.core.remoting.CloseListener listener) remove a Close ListenerList<org.apache.activemq.artemis.core.remoting.CloseListener>
boolean
removeFailureListener
(org.apache.activemq.artemis.core.remoting.FailureListener listener) remove the failure listenerList<org.apache.activemq.artemis.core.remoting.FailureListener>
void
void
setClientID
(String clientId) Sets the client ID associated with this connectionvoid
setCloseListeners
(List<org.apache.activemq.artemis.core.remoting.CloseListener> listeners) void
setFailureListeners
(List<org.apache.activemq.artemis.core.remoting.FailureListener> listeners) set the failure listeners.void
setSubject
(Subject subject) sets the currently associated subject for this connectionMethods 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 Details
-
failureListeners
-
closeListeners
-
transportConnection
-
executor
-
creationTime
protected final long creationTime -
destroyed
protected volatile boolean destroyed -
dataReceived
protected volatile boolean dataReceived
-
-
Constructor Details
-
AbstractRemotingConnection
-
-
Method Details
-
scheduledFlush
public void scheduledFlush()- Specified by:
scheduledFlush
in interfaceRemotingConnection
-
getFailureListeners
Description copied from interface:RemotingConnection
return all the failure listeners- Specified by:
getFailureListeners
in interfaceRemotingConnection
- Returns:
- the listeners
-
isClient
public boolean isClient()Description copied from interface:RemotingConnection
Returns whether or not theRemotingConnection
is a client- Specified by:
isClient
in interfaceRemotingConnection
- Returns:
- true if client, false if a server
-
isDestroyed
public boolean isDestroyed()Description copied from interface:RemotingConnection
Returns true if thisRemotingConnection
has been destroyed.- Specified by:
isDestroyed
in interfaceRemotingConnection
- Returns:
- true if destroyed, otherwise false
-
flush
public void flush()Description copied from interface:RemotingConnection
flush all outstanding data from the connection.- Specified by:
flush
in interfaceRemotingConnection
-
isWritable
- Specified by:
isWritable
in interfaceRemotingConnection
-
callFailureListeners
-
callClosingListeners
protected void callClosingListeners() -
setFailureListeners
public void setFailureListeners(List<org.apache.activemq.artemis.core.remoting.FailureListener> listeners) Description copied from interface:RemotingConnection
set the failure listeners.These will be called in the event of the connection being closed. Any previously added listeners will be removed.
- Specified by:
setFailureListeners
in interfaceRemotingConnection
- Parameters:
listeners
- the listeners to add.
-
getID
Description copied from interface:RemotingConnection
Returns the unique id of theRemotingConnection
.- Specified by:
getID
in interfaceRemotingConnection
- Returns:
- the id
-
getLocalAddress
-
getRemoteAddress
Description copied from interface:RemotingConnection
returns a string representation of the remote address of this connection- Specified by:
getRemoteAddress
in interfaceRemotingConnection
- Returns:
- the remote address
-
addFailureListener
public void addFailureListener(org.apache.activemq.artemis.core.remoting.FailureListener listener) Description copied from interface:RemotingConnection
add a failure listener.The listener will be called in the event of connection failure.
- Specified by:
addFailureListener
in interfaceRemotingConnection
- Parameters:
listener
- the listener
-
removeFailureListener
public boolean removeFailureListener(org.apache.activemq.artemis.core.remoting.FailureListener listener) Description copied from interface:RemotingConnection
remove the failure listener- Specified by:
removeFailureListener
in 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:RemotingConnection
add a CloseListener.This will be called in the event of the connection being closed.
- Specified by:
addCloseListener
in interfaceRemotingConnection
- Parameters:
listener
- the listener to add
-
removeCloseListener
public boolean removeCloseListener(org.apache.activemq.artemis.core.remoting.CloseListener listener) Description copied from interface:RemotingConnection
remove a Close Listener- Specified by:
removeCloseListener
in interfaceRemotingConnection
- Parameters:
listener
- the listener to remove- Returns:
- true if removed
-
removeCloseListeners
- Specified by:
removeCloseListeners
in interfaceRemotingConnection
-
removeFailureListeners
- Specified by:
removeFailureListeners
in interfaceRemotingConnection
-
setCloseListeners
public void setCloseListeners(List<org.apache.activemq.artemis.core.remoting.CloseListener> listeners) - Specified by:
setCloseListeners
in interfaceRemotingConnection
-
createTransportBuffer
Description copied from interface:RemotingConnection
creates a new ActiveMQBuffer of the specified size. For the purpose of i/o outgoing packets- Specified by:
createTransportBuffer
in interfaceRemotingConnection
- Parameters:
size
- the size of buffer required- Returns:
- the buffer
-
getTransportConnection
Description copied from interface:RemotingConnection
return the underlying Connection.- Specified by:
getTransportConnection
in interfaceRemotingConnection
- Returns:
- the connection
-
getCreationTime
public long getCreationTime()Description copied from interface:RemotingConnection
Returns the creation time of theRemotingConnection
.- Specified by:
getCreationTime
in interfaceRemotingConnection
-
checkDataReceived
public boolean checkDataReceived()Description copied from interface:RemotingConnection
returns true if any data has been received since the last time this method was called.- Specified by:
checkDataReceived
in interfaceRemotingConnection
- Returns:
- true if data has been received.
-
fail
Description copied from interface:RemotingConnection
called when the underlying connection fails.- Specified by:
fail
in interfaceRemotingConnection
- Parameters:
me
- the exception that caused the failure
-
close
public void close()- Specified by:
close
in interfaceRemotingConnection
-
asyncFail
Description copied from interface:RemotingConnection
Same thing as fail, but using an executor. semantic of send here, is asynchrounous.- Specified by:
asyncFail
in interfaceRemotingConnection
-
bufferReceived
Description copied from interface:BufferHandler
called by the remoting connection when a buffer is received.- Specified by:
bufferReceived
in interfaceBufferHandler
- Parameters:
connectionID
- the connection the buffer was received onbuffer
- the buffer to decode
-
killMessage
Description copied from interface:RemotingConnection
if slow consumer is killed,send the msessage to client.- Specified by:
killMessage
in interfaceRemotingConnection
-
isSupportReconnect
public boolean isSupportReconnect()Description copied from interface:RemotingConnection
This 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:
isSupportReconnect
in interfaceRemotingConnection
- Returns:
-
isSupportsFlowControl
public boolean isSupportsFlowControl()Description copied from interface:RemotingConnection
Return 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:
isSupportsFlowControl
in interfaceRemotingConnection
- Returns:
-
setSubject
Description copied from interface:RemotingConnection
sets the currently associated subject for this connection- Specified by:
setSubject
in interfaceRemotingConnection
-
getSubject
Description copied from interface:RemotingConnection
the possibly null subject associated with this connection- Specified by:
getSubject
in interfaceRemotingConnection
- Returns:
-
setClientID
Description copied from interface:RemotingConnection
Sets the client ID associated with this connection- Specified by:
setClientID
in interfaceRemotingConnection
-
getClientID
Description copied from interface:RemotingConnection
Returns the Client ID associated with this connection- Specified by:
getClientID
in interfaceRemotingConnection
- Returns:
-
getTransportLocalAddress
Description copied from interface:RemotingConnection
Returns 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:
getTransportLocalAddress
in interfaceRemotingConnection
- Returns:
- the local address of transport connection
-