Package org.apache.activemq.artemis.spi.core.protocol

## Class AbstractRemotingConnection

- java.lang.Object
- - org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection

- All Implemented Interfaces:
    `RemotingConnection`, `BufferHandler`

      public abstract class AbstractRemotingConnection
      extends java.lang.Object
      implements RemotingConnection

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected java.util.List<org.apache.activemq.artemis.core.remoting.CloseListener>` | `closeListeners` |
    `protected long` | `creationTime` |
    `protected boolean` | `dataReceived` |
    `protected java.util.concurrent.Executor` | `executor` |
    `protected java.util.List<org.apache.activemq.artemis.core.remoting.FailureListener>` | `failureListeners` |
    `protected Connection` | `transportConnection` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AbstractRemotingConnection​(Connection transportConnection, java.util.concurrent.Executor executor)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `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.
    `java.util.concurrent.Future` | `asyncFail​(org.apache.activemq.artemis.api.core.ActiveMQException me)` | Same thing as fail, but using an executor.
    `void` | `bufferReceived​(java.lang.Object connectionID, org.apache.activemq.artemis.api.core.ActiveMQBuffer buffer)` | called by the remoting connection when a buffer is received.
    `protected void` | `callClosingListeners()` |
    `protected void` | `callFailureListeners​(org.apache.activemq.artemis.api.core.ActiveMQException me, java.lang.String scaleDownTargetNodeID)` |
    `boolean` | `checkDataReceived()` | returns true if any data has been received since the last time this method was called.
    `org.apache.activemq.artemis.api.core.ActiveMQBuffer` | `createTransportBuffer​(int size)` | creates a new ActiveMQBuffer of the specified size.
    `void` | `fail​(org.apache.activemq.artemis.api.core.ActiveMQException me)` | called when the underlying connection fails.
    `javax.security.auth.Subject` | `getAuditSubject()` |
    `java.lang.String` | `getClientID()` | Returns the Client ID associated with this connection
    `long` | `getCreationTime()` | Returns the creation time of the `RemotingConnection`.
    `java.util.List<org.apache.activemq.artemis.core.remoting.FailureListener>` | `getFailureListeners()` | return all the failure listeners
    `java.lang.Object` | `getID()` | Returns the unique id of the `RemotingConnection`.
    `java.lang.String` | `getLocalAddress()` |
    `java.lang.String` | `getRemoteAddress()` | returns a string representation of the remote address of this connection
    `javax.security.auth.Subject` | `getSubject()` | the possibly null identity associated with this connection
    `Connection` | `getTransportConnection()` | return the underlying Connection.
    `boolean` | `isSupportReconnect()` | This will check if reconnects are supported on the protocol and configuration.
    `boolean` | `isSupportsFlowControl()` | Return true if the protocol supports flow control.
    `boolean` | `isWritable​(ReadyListener callback)` |
    `boolean` | `removeCloseListener​(org.apache.activemq.artemis.core.remoting.CloseListener listener)` | remove a Close Listener
    `java.util.List<org.apache.activemq.artemis.core.remoting.CloseListener>` | `removeCloseListeners()` |
    `boolean` | `removeFailureListener​(org.apache.activemq.artemis.core.remoting.FailureListener listener)` | remove the failure listener
    `java.util.List<org.apache.activemq.artemis.core.remoting.FailureListener>` | `removeFailureListeners()` |
    `void` | `scheduledFlush()` |
    `void` | `setAuditSubject​(javax.security.auth.Subject subject)` |
    `void` | `setClientID​(java.lang.String clientId)` | Sets the client ID associated with this connection
    `void` | `setCloseListeners​(java.util.List<org.apache.activemq.artemis.core.remoting.CloseListener> listeners)` |
    `void` | `setFailureListeners​(java.util.List<org.apache.activemq.artemis.core.remoting.FailureListener> listeners)` | set the failure listeners.

    - ### 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, flush, getProtocolName, getTransportLocalAddress, isClient, isDestroyed, isSameTarget, killMessage`

- - ### Field Detail

    - #### failureListeners

          protected final java.util.List<org.apache.activemq.artemis.core.remoting.FailureListener> failureListeners

    - #### closeListeners

          protected final java.util.List<org.apache.activemq.artemis.core.remoting.CloseListener> closeListeners

    - #### transportConnection

          protected final Connection transportConnection

    - #### executor

          protected final java.util.concurrent.Executor executor

    - #### creationTime

          protected final long creationTime

    - #### dataReceived

          protected volatile boolean dataReceived

  - ### Constructor Detail

    - #### AbstractRemotingConnection

          public AbstractRemotingConnection​(Connection transportConnection,
                                            java.util.concurrent.Executor executor)

  - ### Method Detail

    - #### scheduledFlush

          public void scheduledFlush()

      Specified by:
        `scheduledFlush` in interface `RemotingConnection`

    - #### getFailureListeners

          public java.util.List<org.apache.activemq.artemis.core.remoting.FailureListener> getFailureListeners()

      Description copied from interface: `RemotingConnection`
      return all the failure listeners
      Specified by:
        `getFailureListeners` in interface `RemotingConnection`
      Returns:
        the listeners

    - #### isWritable

          public boolean isWritable​(ReadyListener callback)

      Specified by:
        `isWritable` in interface `RemotingConnection`

    - #### callFailureListeners

          protected void callFailureListeners​(org.apache.activemq.artemis.api.core.ActiveMQException me,
                                              java.lang.String scaleDownTargetNodeID)

    - #### callClosingListeners

          protected void callClosingListeners()

    - #### setFailureListeners

          public void setFailureListeners​(java.util.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 interface `RemotingConnection`
      Parameters:
        `listeners` - the listeners to add.

    - #### getID

          public java.lang.Object getID()

      Description copied from interface: `RemotingConnection`
      Returns the unique id of the `RemotingConnection`.
      Specified by:
        `getID` in interface `RemotingConnection`
      Returns:
        the id

    - #### getLocalAddress

          public java.lang.String getLocalAddress()

    - #### getRemoteAddress

          public java.lang.String getRemoteAddress()

      Description copied from interface: `RemotingConnection`
      returns a string representation of the remote address of this connection
      Specified by:
        `getRemoteAddress` in interface `RemotingConnection`
      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 interface `RemotingConnection`
      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 interface `RemotingConnection`
      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 interface `RemotingConnection`
      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 interface `RemotingConnection`
      Parameters:
        `listener` - the listener to remove
      Returns:
        true if removed

    - #### removeCloseListeners

          public java.util.List<org.apache.activemq.artemis.core.remoting.CloseListener> removeCloseListeners()

      Specified by:
        `removeCloseListeners` in interface `RemotingConnection`

    - #### removeFailureListeners

          public java.util.List<org.apache.activemq.artemis.core.remoting.FailureListener> removeFailureListeners()

      Specified by:
        `removeFailureListeners` in interface `RemotingConnection`

    - #### setCloseListeners

          public void setCloseListeners​(java.util.List<org.apache.activemq.artemis.core.remoting.CloseListener> listeners)

      Specified by:
        `setCloseListeners` in interface `RemotingConnection`

    - #### createTransportBuffer

          public org.apache.activemq.artemis.api.core.ActiveMQBuffer createTransportBuffer​(int size)

      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 interface `RemotingConnection`
      Parameters:
        `size` - the size of buffer required
      Returns:
        the buffer

    - #### getTransportConnection

          public Connection getTransportConnection()

      Description copied from interface: `RemotingConnection`
      return the underlying Connection.
      Specified by:
        `getTransportConnection` in interface `RemotingConnection`
      Returns:
        the connection

    - #### getCreationTime

          public long getCreationTime()

      Description copied from interface: `RemotingConnection`
      Returns the creation time of the `RemotingConnection`.
      Specified by:
        `getCreationTime` in interface `RemotingConnection`

    - #### 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 interface `RemotingConnection`
      Returns:
        true if data has been received.

    - #### 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 interface `RemotingConnection`
      Returns:

    - #### fail

          public void fail​(org.apache.activemq.artemis.api.core.ActiveMQException me)

      Description copied from interface: `RemotingConnection`
      called when the underlying connection fails.
      Specified by:
        `fail` in interface `RemotingConnection`
      Parameters:
        `me` - the exception that caused the failure

    - #### asyncFail

          public java.util.concurrent.Future asyncFail​(org.apache.activemq.artemis.api.core.ActiveMQException me)

      Description copied from interface: `RemotingConnection`
      Same thing as fail, but using an executor. semantic of send here, is asynchrounous.
      Specified by:
        `asyncFail` in interface `RemotingConnection`

    - #### bufferReceived

          public void bufferReceived​(java.lang.Object connectionID,
                                     org.apache.activemq.artemis.api.core.ActiveMQBuffer buffer)

      Description copied from interface: `BufferHandler`
      called by the remoting connection when a buffer is received.
      Specified by:
        `bufferReceived` in interface `BufferHandler`
      Parameters:
        `connectionID` - the connection the buffer was received on
        `buffer` - the buffer to decode

    - #### 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 interface `RemotingConnection`
      Returns:

    - #### setAuditSubject

          public void setAuditSubject​(javax.security.auth.Subject subject)

      Specified by:
        `setAuditSubject` in interface `RemotingConnection`

    - #### getAuditSubject

          public javax.security.auth.Subject getAuditSubject()

      Specified by:
        `getAuditSubject` in interface `RemotingConnection`

    - #### getSubject

          public javax.security.auth.Subject getSubject()

      Description copied from interface: `RemotingConnection`
      the possibly null identity associated with this connection
      Specified by:
        `getSubject` in interface `RemotingConnection`
      Returns:

    - #### setClientID

          public void setClientID​(java.lang.String clientId)

      Description copied from interface: `RemotingConnection`
      Sets the client ID associated with this connection
      Specified by:
        `setClientID` in interface `RemotingConnection`

    - #### getClientID

          public java.lang.String getClientID()

      Description copied from interface: `RemotingConnection`
      Returns the Client ID associated with this connection
      Specified by:
        `getClientID` in interface `RemotingConnection`
      Returns: