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

## Interface RemotingConnection

- All Superinterfaces:
    `BufferHandler`
  All Known Implementing Classes:
    `AbstractRemotingConnection`

      public interface RemotingConnection
      extends BufferHandler

  A RemotingConnection is a connection between a client and a server. Perhaps a better name for this class now would be ProtocolConnection as this represents the link with the used protocol

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default 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.
    `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` | `destroy()` | destroys this connection.
    `void` | `disconnect​(boolean criticalError)` | Disconnect the connection, closing all channels
    `void` | `disconnect​(java.lang.String scaleDownNodeID, boolean criticalError)` | Disconnect the connection, closing all channels
    `default void` | `disconnect​(org.apache.activemq.artemis.api.core.DisconnectReason reason, java.lang.String targetNodeID, TransportConfiguration targetConnector)` | Disconnect the connection, closing all channels
    `void` | `fail​(org.apache.activemq.artemis.api.core.ActiveMQException me)` | called when the underlying connection fails.
    `void` | `fail​(org.apache.activemq.artemis.api.core.ActiveMQException me, java.lang.String scaleDownTargetNodeID)` | called when the underlying connection fails.
    `void` | `flush()` | flush all outstanding data from the connection.
    `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` | `getProtocolName()` | Returns the name of the protocol for this Remoting Connection
    `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.
    `java.lang.String` | `getTransportLocalAddress()` | Returns a string representation of the local address this connection is connected to.
    `boolean` | `isClient()` | Returns whether or not the `RemotingConnection` is a client
    `boolean` | `isDestroyed()` | Returns true if this `RemotingConnection` has been destroyed.
    `default boolean` | `isSameTarget​(TransportConfiguration... configs)` |
    `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)` |
    `void` | `killMessage​(org.apache.activemq.artemis.api.core.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 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 cID)` | 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 interface org.apache.activemq.artemis.spi.core.remoting.BufferHandler

      `bufferReceived, endOfBatch`

- - ### Method Detail

    - #### getID

          java.lang.Object getID()

      Returns the unique id of the `RemotingConnection`.
      Returns:
        the id

    - #### getCreationTime

          long getCreationTime()

      Returns the creation time of the `RemotingConnection`.

    - #### getRemoteAddress

          java.lang.String getRemoteAddress()

      returns a string representation of the remote address of this connection
      Returns:
        the remote address

    - #### scheduledFlush

          void scheduledFlush()

    - #### addFailureListener

          void addFailureListener​(org.apache.activemq.artemis.core.remoting.FailureListener listener)

      add a failure listener.

      The listener will be called in the event of connection failure.

      Parameters:
        `listener` - the listener

    - #### removeFailureListener

          boolean removeFailureListener​(org.apache.activemq.artemis.core.remoting.FailureListener listener)

      remove the failure listener
      Parameters:
        `listener` - the lister to remove
      Returns:
        true if removed

    - #### addCloseListener

          void addCloseListener​(org.apache.activemq.artemis.core.remoting.CloseListener listener)

      add a CloseListener.

      This will be called in the event of the connection being closed.

      Parameters:
        `listener` - the listener to add

    - #### removeCloseListener

          boolean removeCloseListener​(org.apache.activemq.artemis.core.remoting.CloseListener listener)

      remove a Close Listener
      Parameters:
        `listener` - the listener to remove
      Returns:
        true if removed

    - #### removeCloseListeners

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

    - #### setCloseListeners

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

    - #### getFailureListeners

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

      return all the failure listeners
      Returns:
        the listeners

    - #### removeFailureListeners

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

    - #### setFailureListeners

          void setFailureListeners​(java.util.List<org.apache.activemq.artemis.core.remoting.FailureListener> listeners)

      set the failure listeners.

      These will be called in the event of the connection being closed. Any previously added listeners will be removed.

      Parameters:
        `listeners` - the listeners to add.

    - #### createTransportBuffer

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

      creates a new ActiveMQBuffer of the specified size. For the purpose of i/o outgoing packets
      Parameters:
        `size` - the size of buffer required
      Returns:
        the buffer

    - #### fail

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

      called when the underlying connection fails.
      Parameters:
        `me` - the exception that caused the failure

    - #### asyncFail

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

      Same thing as fail, but using an executor. semantic of send here, is asynchrounous.
      Parameters:
        `me` -

    - #### fail

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

      called when the underlying connection fails.
      Parameters:
        `me` - the exception that caused the failure
        `scaleDownTargetNodeID` - the ID of the node where scale down is targeted

    - #### destroy

          void destroy()

      destroys this connection.

    - #### getTransportConnection

          Connection getTransportConnection()

      return the underlying Connection.
      Returns:
        the connection

    - #### isClient

          boolean isClient()

      Returns whether or not the `RemotingConnection` is a client
      Returns:
        true if client, false if a server

    - #### isDestroyed

          boolean isDestroyed()

      Returns true if this `RemotingConnection` has been destroyed.
      Returns:
        true if destroyed, otherwise false

    - #### disconnect

          void disconnect​(boolean criticalError)

      Disconnect the connection, closing all channels

    - #### disconnect

          void disconnect​(java.lang.String scaleDownNodeID,
                          boolean criticalError)

      Disconnect the connection, closing all channels

    - #### disconnect

          default void disconnect​(org.apache.activemq.artemis.api.core.DisconnectReason reason,
                                  java.lang.String targetNodeID,
                                  TransportConfiguration targetConnector)

      Disconnect the connection, closing all channels

    - #### checkDataReceived

          boolean checkDataReceived()

      returns true if any data has been received since the last time this method was called.
      Returns:
        true if data has been received.

    - #### flush

          void flush()

      flush all outstanding data from the connection.

    - #### isWritable

          boolean isWritable​(ReadyListener callback)

    - #### killMessage

          void killMessage​(org.apache.activemq.artemis.api.core.SimpleString nodeID)

      if slow consumer is killed,send the msessage to client.

    - #### isSupportReconnect

          boolean isSupportReconnect()

      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.
      Returns:

    - #### isSupportsFlowControl

          boolean isSupportsFlowControl()

      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.
      Returns:

    - #### setAuditSubject

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

    - #### getAuditSubject

          javax.security.auth.Subject getAuditSubject()

    - #### getSubject

          javax.security.auth.Subject getSubject()

      the possibly null identity associated with this connection
      Returns:

    - #### getProtocolName

          java.lang.String getProtocolName()

      Returns the name of the protocol for this Remoting Connection
      Returns:

    - #### setClientID

          void setClientID​(java.lang.String cID)

      Sets the client ID associated with this connection
      Parameters:
        `cID` -

    - #### getClientID

          java.lang.String getClientID()

      Returns the Client ID associated with this connection
      Returns:

    - #### getTransportLocalAddress

          java.lang.String getTransportLocalAddress()

      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.
      Returns:
        the local address of transport connection

    - #### isSameTarget

          default boolean isSameTarget​(TransportConfiguration... configs)