Class AMQCommand

java.lang.Object
com.rabbitmq.client.impl.AMQCommand
All Implemented Interfaces:
Command

public class AMQCommand extends Object implements Command
AMQP 0-9-1-specific implementation of Command which accumulates method, header and body from a series of frames, unless these are supplied at construction time.

Concurrency

This class is thread-safe.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    EMPTY_FRAME_SIZE = 8 = 1 + 2 + 4 + 1 1 byte of frame type 2 bytes of channel number 4 bytes of frame payload length 1 byte of payload trailer FRAME_END byte See checkEmptyFrameSize(), an assertion checked at startup.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a command ready to fill in by reading frames
    Construct a command with just a method, and without header or body.
    AMQCommand(Method method, AMQContentHeader contentHeader, byte[] body)
    Construct a command with a specified method, header and body.
    AMQCommand(Method method, AMQContentHeader contentHeader, byte[] body, int maxBodyLength)
    Construct a command with a specified method, header and body.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Called to check internal code assumptions.
    byte[]
    Public API - Retrieves the body byte array that travelled as part of this Command, if any.
    Public API - Retrieves the ContentHeader subclass instance held as part of this Command, if any.
    Public API - Retrieves the Method held within this Command.
    boolean
     
     
    toString(boolean suppressBody)
     
    void
    Sends this command down the named channel on the channel's connection, possibly in multiple frames.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • EMPTY_FRAME_SIZE

      public static final int EMPTY_FRAME_SIZE
      EMPTY_FRAME_SIZE = 8 = 1 + 2 + 4 + 1
      • 1 byte of frame type
      • 2 bytes of channel number
      • 4 bytes of frame payload length
      • 1 byte of payload trailer FRAME_END byte
      See checkEmptyFrameSize(), an assertion checked at startup.
      See Also:
  • Constructor Details

    • AMQCommand

      public AMQCommand()
      Construct a command ready to fill in by reading frames
    • AMQCommand

      public AMQCommand(Method method)
      Construct a command with just a method, and without header or body.
      Parameters:
      method - the wrapped method
    • AMQCommand

      public AMQCommand(Method method, AMQContentHeader contentHeader, byte[] body)
      Construct a command with a specified method, header and body.
      Parameters:
      method - the wrapped method
      contentHeader - the wrapped content header
      body - the message body data
    • AMQCommand

      public AMQCommand(Method method, AMQContentHeader contentHeader, byte[] body, int maxBodyLength)
      Construct a command with a specified method, header and body.
      Parameters:
      method - the wrapped method
      contentHeader - the wrapped content header
      body - the message body data
      maxBodyLength - the maximum size for an inbound message body
  • Method Details

    • getMethod

      public Method getMethod()
      Public API - Retrieves the Method held within this Command. Downcast to concrete (implementation-specific!) subclasses as necessary.
      Specified by:
      getMethod in interface Command
      Returns:
      the command's method.
    • getContentHeader

      public AMQContentHeader getContentHeader()
      Public API - Retrieves the ContentHeader subclass instance held as part of this Command, if any. Downcast to one of the inner classes of AMQP, for instance AMQP.BasicProperties, as appropriate.
      Specified by:
      getContentHeader in interface Command
      Returns:
      the Command's ContentHeader, or null if none
    • getContentBody

      public byte[] getContentBody()
      Public API - Retrieves the body byte array that travelled as part of this Command, if any.
      Specified by:
      getContentBody in interface Command
      Returns:
      the Command's content body, or null if none
    • handleFrame

      public boolean handleFrame(Frame f) throws IOException
      Throws:
      IOException
    • transmit

      public void transmit(AMQChannel channel) throws IOException
      Sends this command down the named channel on the channel's connection, possibly in multiple frames.
      Parameters:
      channel - the channel on which to transmit the command
      Throws:
      IOException - if an error is encountered
    • toString

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

      public String toString(boolean suppressBody)
    • checkPreconditions

      public static void checkPreconditions()
      Called to check internal code assumptions.