public class

Frame

extends Object
java.lang.Object
   ↳ com.rabbitmq.client.impl.Frame

Class Overview

Represents an AMQP wire-protocol frame, with frame type, channel number, and payload bytes. TODO: make state private

Summary

Fields
public final int channel Frame channel number, 0-65535
public final int type Frame type code
Public Constructors
Frame(int type, int channel)
Constructs a frame for output with a type and a channel number and a fresh accumulator waiting for payload.
Frame(int type, int channel, byte[] payload)
Constructs a frame for input with a type, a channel number and a payload byte array.
Public Methods
static long arraySize(List<?> values)
Computes the AMQP wire-protocol length of an encoded field-array
static Frame fromBodyFragment(int channelNumber, byte[] body, int offset, int length)
DataInputStream getInputStream()
Public API - retrieves a new DataInputStream streaming over the payload
DataOutputStream getOutputStream()
Public API - retrieves a fresh DataOutputStream streaming into the accumulator
byte[] getPayload()
Public API - retrieves the frame payload
static void protocolVersionMismatch(DataInputStream is)
Private API - A protocol version mismatch is detected by checking the three next bytes if a frame type of (int)'A' is read from an input stream.
static Frame readFrom(DataInputStream is)
Protected API - Factory method to instantiate a Frame by reading an AMQP-wire-protocol frame from the given input stream.
static long tableSize(Map<StringObject> table)
Computes the AMQP wire-protocol length of protocol-encoded table entries.
String toString()
void writeTo(DataOutputStream os)
Public API - writes this Frame to the given DataOutputStream
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public final int channel

Frame channel number, 0-65535

public final int type

Frame type code

Public Constructors

public Frame (int type, int channel)

Constructs a frame for output with a type and a channel number and a fresh accumulator waiting for payload.

public Frame (int type, int channel, byte[] payload)

Constructs a frame for input with a type, a channel number and a payload byte array.

Public Methods

public static long arraySize (List<?> values)

Computes the AMQP wire-protocol length of an encoded field-array

public static Frame fromBodyFragment (int channelNumber, byte[] body, int offset, int length)

Throws
IOException

public DataInputStream getInputStream ()

Public API - retrieves a new DataInputStream streaming over the payload

public DataOutputStream getOutputStream ()

Public API - retrieves a fresh DataOutputStream streaming into the accumulator

public byte[] getPayload ()

Public API - retrieves the frame payload

public static void protocolVersionMismatch (DataInputStream is)

Private API - A protocol version mismatch is detected by checking the three next bytes if a frame type of (int)'A' is read from an input stream. If the next three bytes are 'M', 'Q' and 'P', then it's likely the broker is trying to tell us we are speaking the wrong AMQP protocol version.

Throws
MalformedFrameException if an AMQP protocol version mismatch is detected
MalformedFrameException if a corrupt AMQP protocol identifier is read
IOException

public static Frame readFrom (DataInputStream is)

Protected API - Factory method to instantiate a Frame by reading an AMQP-wire-protocol frame from the given input stream.

Returns
  • a new Frame if we read a frame successfully, otherwise null
Throws
IOException

public static long tableSize (Map<StringObject> table)

Computes the AMQP wire-protocol length of protocol-encoded table entries.

public String toString ()

public void writeTo (DataOutputStream os)

Public API - writes this Frame to the given DataOutputStream

Throws
IOException