Class CommandAssembler

java.lang.Object
com.rabbitmq.client.impl.CommandAssembler

final class CommandAssembler extends Object
Class responsible for piecing together a command from a series of Frames.

Concurrency
This class is thread-safe, since all methods are synchronised. Callers should not synchronise on objects of this class unless they are sole owners.

See Also:
  • Field Details

    • EMPTY_BYTE_ARRAY

      private static final byte[] EMPTY_BYTE_ARRAY
    • state

      private CommandAssembler.CAState state
    • method

      private Method method
      The method for this command
    • contentHeader

      private AMQContentHeader contentHeader
      The content header for this command
    • bodyN

      private final List<byte[]> bodyN
      The fragments of this command's content body - a list of byte[]
    • bodyLength

      private int bodyLength
      sum of the lengths of all fragments
    • remainingBodyBytes

      private long remainingBodyBytes
      No bytes of content body not yet accumulated
    • maxBodyLength

      private final int maxBodyLength
  • Constructor Details

    • CommandAssembler

      public CommandAssembler(Method method, AMQContentHeader contentHeader, byte[] body, int maxBodyLength)
  • Method Details

    • getMethod

      public Method getMethod()
    • getContentHeader

      public AMQContentHeader getContentHeader()
    • isComplete

      public boolean isComplete()
      Returns:
      true if the command is complete
    • updateContentBodyState

      private void updateContentBodyState()
      Decides whether more body frames are expected
    • consumeMethodFrame

      private void consumeMethodFrame(Frame f) throws IOException
      Throws:
      IOException
    • consumeHeaderFrame

      private void consumeHeaderFrame(Frame f) throws IOException
      Throws:
      IOException
    • consumeBodyFrame

      private void consumeBodyFrame(Frame f)
    • coalesceContentBody

      private byte[] coalesceContentBody()
      Stitches together a fragmented content body into a single byte array
    • getContentBody

      public byte[] getContentBody()
    • appendBodyFragment

      private void appendBodyFragment(byte[] fragment)
    • handleFrame

      public boolean handleFrame(Frame f) throws IOException
      Parameters:
      f - frame to be incorporated
      Returns:
      true if command becomes complete
      Throws:
      IOException - if error reading frame