Class SocketFrameHandler

java.lang.Object
com.rabbitmq.client.impl.SocketFrameHandler
All Implemented Interfaces:
FrameHandler, NetworkConnection

public class SocketFrameHandler extends Object implements FrameHandler
A socket-based frame handler.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • _socket

      private final Socket _socket
      The underlying socket
    • _shutdownExecutor

      private final ExecutorService _shutdownExecutor
      Optional ExecutorService for final flush.
    • _inputStream

      private final DataInputStream _inputStream
      Socket's inputstream - data from the broker - synchronized on
    • _inputStreamLock

      private final Lock _inputStreamLock
    • _outputStream

      private final DataOutputStream _outputStream
      Socket's outputstream - data to the broker - synchronized on
    • _outputStreamLock

      private final Lock _outputStreamLock
    • maxInboundMessageBodySize

      private final int maxInboundMessageBodySize
    • SOCKET_CLOSING_TIMEOUT

      public static final int SOCKET_CLOSING_TIMEOUT
      Time to linger before closing the socket forcefully.
      See Also:
  • Constructor Details

  • Method Details

    • getAddress

      public InetAddress getAddress()
      Description copied from interface: NetworkConnection
      Retrieve address of peer.
      Specified by:
      getAddress in interface NetworkConnection
    • getLocalAddress

      public InetAddress getLocalAddress()
      Description copied from interface: NetworkConnection
      Retrieve the local host.
      Specified by:
      getLocalAddress in interface NetworkConnection
      Returns:
      the client socket address.
    • getInputStream

      public DataInputStream getInputStream()
    • getPort

      public int getPort()
      Description copied from interface: NetworkConnection
      Retrieve port number of peer.
      Specified by:
      getPort in interface NetworkConnection
    • getLocalPort

      public int getLocalPort()
      Description copied from interface: NetworkConnection
      Retrieve the local port number.
      Specified by:
      getLocalPort in interface NetworkConnection
      Returns:
      the client socket port number
    • setTimeout

      public void setTimeout(int timeoutMs) throws SocketException
      Description copied from interface: FrameHandler
      Set the underlying socket's read timeout in milliseconds, if applicable.
      Specified by:
      setTimeout in interface FrameHandler
      Parameters:
      timeoutMs - The timeout in milliseconds
      Throws:
      SocketException
    • getTimeout

      public int getTimeout() throws SocketException
      Description copied from interface: FrameHandler
      Get the underlying socket's read timeout in milliseconds.
      Specified by:
      getTimeout in interface FrameHandler
      Returns:
      The timeout in milliseconds
      Throws:
      SocketException
    • sendHeader

      public void sendHeader(int major, int minor) throws IOException
      Write a 0-8-style connection header to the underlying socket, containing the specified version information, kickstarting the AMQP protocol version negotiation process.
      Parameters:
      major - major protocol version number
      minor - minor protocol version number
      Throws:
      IOException - if there is a problem accessing the connection
      See Also:
    • sendHeader

      public void sendHeader(int major, int minor, int revision) throws IOException
      Write a 0-9-1-style connection header to the underlying socket, containing the specified version information, kickstarting the AMQP protocol version negotiation process.
      Parameters:
      major - major protocol version number
      minor - minor protocol version number
      revision - protocol revision number
      Throws:
      IOException - if there is a problem accessing the connection
      See Also:
    • sendHeader

      public void sendHeader() throws IOException
      Description copied from interface: FrameHandler
      Send the initial connection header, thus kickstarting the AMQP protocol version negotiation process and putting the underlying connection in a state such that the next layer of startup can proceed.
      Specified by:
      sendHeader in interface FrameHandler
      Throws:
      IOException - if there is a problem accessing the connection
    • initialize

      public void initialize(AMQConnection connection)
      Specified by:
      initialize in interface FrameHandler
    • readFrame

      public Frame readFrame() throws IOException
      Description copied from interface: FrameHandler
      Read a Frame from the underlying data connection.
      Specified by:
      readFrame in interface FrameHandler
      Returns:
      an incoming Frame, or null if there is none
      Throws:
      IOException - if there is a problem accessing the connection
    • writeFrame

      public void writeFrame(Frame frame) throws IOException
      Description copied from interface: FrameHandler
      Write a Frame to the underlying data connection.
      Specified by:
      writeFrame in interface FrameHandler
      Parameters:
      frame - the Frame to transmit
      Throws:
      IOException - if there is a problem accessing the connection
    • flush

      public void flush() throws IOException
      Description copied from interface: FrameHandler
      Flush the underlying data connection.
      Specified by:
      flush in interface FrameHandler
      Throws:
      IOException - if there is a problem accessing the connection
    • close

      public void close()
      Description copied from interface: FrameHandler
      Close the underlying data connection (complaint not permitted).
      Specified by:
      close in interface FrameHandler