java.lang.Object
org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnection
All Implemented Interfaces:
Connection
Direct Known Subclasses:
NettyServerConnection

public class NettyConnection extends Object implements Connection
  • Field Details

    • channel

      protected final io.netty.channel.Channel channel
  • Constructor Details

  • Method Details

    • getEventLoop

      public io.netty.channel.EventLoop getEventLoop()
      Specified by:
      getEventLoop in interface Connection
    • getNettyChannel

      public final io.netty.channel.Channel getNettyChannel()
    • setAutoRead

      public final void setAutoRead(boolean autoRead)
      Description copied from interface: Connection
      This will disable reading from the channel. This is basically the same as blocking the reading.
      Specified by:
      setAutoRead in interface Connection
    • isWritable

      public final boolean isWritable(ReadyListener callback)
      Specified by:
      isWritable in interface Connection
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface Connection
    • fireReady

      public final void fireReady(boolean ready)
      Specified by:
      fireReady in interface Connection
    • forceClose

      public final void forceClose()
      Description copied from interface: Connection
      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.
      Specified by:
      forceClose in interface Connection
    • getChannel

      public final io.netty.channel.Channel getChannel()
      This is exposed so users would have the option to look at any data through interceptors
    • getProtocolConnection

      public final RemotingConnection getProtocolConnection()
      Specified by:
      getProtocolConnection in interface Connection
    • setProtocolConnection

      public final void setProtocolConnection(RemotingConnection protocolConnection)
      Specified by:
      setProtocolConnection in interface Connection
    • close

      public final void close()
      Description copied from interface: Connection
      Closes the connection.
      Specified by:
      close in interface Connection
    • createTransportBuffer

      public ActiveMQBuffer createTransportBuffer(int size)
      Description copied from interface: Connection
      Create a new ActiveMQBuffer of the given size.
      Specified by:
      createTransportBuffer in interface Connection
      Parameters:
      size - the size of buffer to create
      Returns:
      the new buffer
    • getID

      public final Object getID()
      Description copied from interface: Connection
      Returns the unique id of this wire.
      Specified by:
      getID in interface Connection
      Returns:
      the unique id of this wire
    • checkFlushBatchBuffer

      public final void checkFlushBatchBuffer()
      Description copied from interface: Connection
      Called periodically to flush any data in the batch buffer
      Specified by:
      checkFlushBatchBuffer in interface Connection
    • write

      public final void write(ActiveMQBuffer buffer)
      Description copied from interface: Connection
      writes the buffer to the connection with no flushing or batching
      Specified by:
      write in interface Connection
      Parameters:
      buffer - the buffer to write
    • write

      public void write(ActiveMQBuffer buffer, boolean requestFlush)
      Description copied from interface: Connection
      writes the buffer to the connection and if flush is true request to flush the buffer (and any previous un-flushed ones) into the wire.
      Specified by:
      write in interface Connection
      Parameters:
      buffer - the buffer to write
      requestFlush - whether to request flush onto the wire
    • flush

      public void flush()
      Description copied from interface: Connection
      Request to flush any previous written buffers into the wire.
      Specified by:
      flush in interface Connection
    • write

      public final void write(ActiveMQBuffer buffer, boolean flush, boolean batched)
      Description copied from interface: Connection
      writes the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.
      Specified by:
      write in interface 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
    • blockUntilWritable

      public final boolean blockUntilWritable(long timeout, TimeUnit timeUnit)
      Description copied from interface: Connection
      Causes the current thread to wait until the connection is writable unless the specified waiting time elapses. The available capacity of the connection could change concurrently hence this method is suitable to perform precise flow-control only in a single writer case, while its precision decrease inversely proportional with the rate and the number of concurrent writers. If the current thread is not allowed to block the timeout will be ignored dependently on the connection type.
      Specified by:
      blockUntilWritable in interface Connection
      Parameters:
      timeout - the maximum time to wait
      timeUnit - the time unit of the timeout argument
      Returns:
      true if the connection is writable, false otherwise
    • write

      public final void write(ActiveMQBuffer buffer, boolean flush, boolean batched, io.netty.channel.ChannelFutureListener futureListener)
      Description copied from interface: Connection
      writes the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.
      Specified by:
      write in interface 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
    • getRemoteAddress

      public final String getRemoteAddress()
      Description copied from interface: Connection
      Returns the string representation of the remote address this connection is connected to.
      Specified by:
      getRemoteAddress in interface Connection
      Returns:
      the string representation of the remote address this connection is connected to
    • getLocalAddress

      public final String getLocalAddress()
      Description copied from interface: Connection
      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:
      getLocalAddress in interface Connection
      Returns:
      the local address
    • isDirectDeliver

      public final boolean isDirectDeliver()
      Specified by:
      isDirectDeliver in interface Connection
    • getDefaultActiveMQPrincipal

      public final ActiveMQPrincipal getDefaultActiveMQPrincipal()
      Specified by:
      getDefaultActiveMQPrincipal in interface Connection
    • getConnectorConfig

      public final TransportConfiguration getConnectorConfig()
      Description copied from interface: Connection
      Generates a TransportConfiguration to be used to connect to the same target this is connected to.
      Specified by:
      getConnectorConfig in interface Connection
      Returns:
      TransportConfiguration
    • isUsingProtocolHandling

      public final boolean isUsingProtocolHandling()
      Description copied from interface: Connection
      the InVM Connection has some special handling as it doesn't use Netty ProtocolChannel we will use this method Instead of using instanceof
      Specified by:
      isUsingProtocolHandling in interface Connection
    • isSameTarget

      public boolean isSameTarget(TransportConfiguration... configs)
      Specified by:
      isSameTarget in interface Connection
    • toString

      public final String toString()
      Overrides:
      toString in class Object