org.apache.activemq.artemis.spi.core.remoting

## Interface Connection

-     public interface Connection

  The connection used by a channel to write data to.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkFlushBatchBuffer()` Called periodically to flush any data in the batch buffer
    `void` | `close()` Closes the connection.
    `ActiveMQBuffer` | `createTransportBuffer(int size)` Create a new ActiveMQBuffer of the given size.
    `void` | `fireReady(boolean ready)`
    `void` | `forceClose()` This should close the internal channel without calling any listeners.
    `TransportConfiguration` | `getConnectorConfig()` Generates a `TransportConfiguration` to be used to connect to the same target this is connected to.
    `org.apache.activemq.artemis.core.security.ActiveMQPrincipal` | `getDefaultActiveMQPrincipal()`
    `Object` | `getID()` returns the unique id of this wire.
    `String` | `getLocalAddress()` Returns a string representation of the local address this connection is connected to.
    `RemotingConnection` | `getProtocolConnection()`
    `String` | `getRemoteAddress()` Returns a string representation of the remote address this connection is connected to.
    `boolean` | `isUsingProtocolHandling()` the InVM Connection has some special handling as it doesn't use Netty ProtocolChannel we will use this method Instead of using instanceof
    `boolean` | `isWritable(ReadyListener listener)`
    `void` | `setProtocolConnection(RemotingConnection connection)`
    `void` | `write(ActiveMQBuffer buffer)` writes the buffer to the connection with no flushing or batching
    `void` | `write(ActiveMQBuffer buffer, boolean flush, boolean batched)` writes the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.
    `void` | `write(ActiveMQBuffer buffer, boolean flush, boolean batched, io.netty.channel.ChannelFutureListener futureListener)` writes the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.

- - ### Method Detail

    - #### createTransportBuffer

          ActiveMQBuffer createTransportBuffer(int size)

      Create a new ActiveMQBuffer of the given size.
      Parameters:
        `size` - the size of buffer to create
      Returns:
        the new buffer.

    - #### getProtocolConnection

          RemotingConnection getProtocolConnection()

    - #### setProtocolConnection

          void setProtocolConnection(RemotingConnection connection)

    - #### isWritable

          boolean isWritable(ReadyListener listener)

    - #### fireReady

          void fireReady(boolean ready)

    - #### getID

          Object getID()

      returns the unique id of this wire.
      Returns:
        the id

    - #### write

          void write(ActiveMQBuffer buffer,
                     boolean flush,
                     boolean batched)

      writes the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.
      Parameters:
        `buffer` - the buffer to write
        `flush` - whether to flush the buffers onto the wire
        `batched` - whether the packet is allowed to batched for better performance

    - #### write

          void write(ActiveMQBuffer buffer,
                     boolean flush,
                     boolean batched,
                     io.netty.channel.ChannelFutureListener futureListener)

      writes the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.
      Parameters:
        `buffer` - the buffer to write
        `flush` - whether to flush the buffers onto the wire
        `batched` - whether the packet is allowed to batched for better performance

    - #### write

          void write(ActiveMQBuffer buffer)

      writes the buffer to the connection with no flushing or batching
      Parameters:
        `buffer` - the buffer to write

    - #### forceClose

          void forceClose()

      This should close the internal channel without calling any listeners. This is to avoid a situation where the broker is busy writing on an internal thread. This should close the socket releasing any pending threads.

    - #### close

          void close()

      Closes the connection.

    - #### getRemoteAddress

          String getRemoteAddress()

      Returns a string representation of the remote address this connection is connected to.
      Returns:
        the remote address

    - #### getLocalAddress

          String getLocalAddress()

      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

    - #### checkFlushBatchBuffer

          void checkFlushBatchBuffer()

      Called periodically to flush any data in the batch buffer

    - #### getConnectorConfig

          TransportConfiguration getConnectorConfig()

      Generates a `TransportConfiguration` to be used to connect to the same target this is connected to.
      Returns:
        TransportConfiguration

    - #### getDefaultActiveMQPrincipal

          org.apache.activemq.artemis.core.security.ActiveMQPrincipal getDefaultActiveMQPrincipal()

    - #### isUsingProtocolHandling

          boolean isUsingProtocolHandling()

      the InVM Connection has some special handling as it doesn't use Netty ProtocolChannel we will use this method Instead of using instanceof
      Returns:

Copyright © 2016. All rights reserved.