Package com.rabbitmq.client.impl
Class Frame
java.lang.Object
com.rabbitmq.client.impl.Frame
Represents an AMQP wire-protocol frame, with frame type, channel number, and payload bytes.
TODO: make state private
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
Computes the AMQP wire-protocol length of an encoded field-array of type Object[]static long
Computes the AMQP 0-9-1 wire-protocol length of an encoded field-array of type Liststatic Frame
fromBodyFragment
(int channelNumber, byte[] body, int offset, int length) Public API - retrieves a new DataInputStream streaming over the payloadPublic API - retrieves a fresh DataOutputStream streaming into the accumulatorbyte[]
Public API - retrieves the frame payloadstatic void
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, int maxPayloadSize) Protected API - Factory method to instantiate a Frame by reading an AMQP-wire-protocol frame from the given input stream.int
size()
static long
Computes the AMQP wire-protocol length of protocol-encoded table entries.toString()
void
Public API - writes this Frame to the given DataOutputStream
-
Field Details
-
type
public final int typeFrame type code -
channel
public final int channelFrame channel number, 0-65535
-
-
Constructor Details
-
Frame
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. -
Frame
public Frame(int type, int channel, byte[] payload) Constructs a frame for input with a type, a channel number and a payload byte array.
-
-
Method Details
-
fromBodyFragment
public static Frame fromBodyFragment(int channelNumber, byte[] body, int offset, int length) throws IOException - Throws:
IOException
-
readFrom
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
-
protocolVersionMismatch
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 detectedMalformedFrameException
- if a corrupt AMQP protocol identifier is readIOException
-
writeTo
Public API - writes this Frame to the given DataOutputStream- Throws:
IOException
-
size
public int size() -
getPayload
public byte[] getPayload()Public API - retrieves the frame payload -
getInputStream
Public API - retrieves a new DataInputStream streaming over the payload -
getOutputStream
Public API - retrieves a fresh DataOutputStream streaming into the accumulator -
toString
-
tableSize
Computes the AMQP wire-protocol length of protocol-encoded table entries.- Throws:
UnsupportedEncodingException
-
arraySize
Computes the AMQP 0-9-1 wire-protocol length of an encoded field-array of type List- Throws:
UnsupportedEncodingException
-
arraySize
Computes the AMQP wire-protocol length of an encoded field-array of type Object[]- Throws:
UnsupportedEncodingException
-