[rabbitmq-discuss] encoding content body frames
tonyg at lshift.net
Wed Jul 16 11:27:37 BST 2008
Aman Gupta wrote:
> The content body payload is an opaque binary block followed by a frame end octet:
That's right - the language in the spec isn't quite precise enough to
pin down the expected behaviour here. The way it is intended to be, and
the way the current implementations work, is as follows.
Each frame (no matter its type) is built from
- 7 bytes of header
- N bytes of body
- 1 byte of frame end marker
So for method, content header, and content body frames (and also the
others mentioned in the spec), the same generic pattern is used.
In more detail, a full frame looks like
- 1 byte of type (method, content header, content body etc)
- 2 bytes of channel number
- 4 bytes of payload size (= N)
- N bytes of payload
- 1 byte of frame end marker (0xCE)
Note that the payload size word counts neither the 7 bytes of header nor
the 1 bytes of frame end marker.
Once a complete frame is read, its type is examined, and the payload can
be further decoded if the frame is a method or content header frame.
More information about the rabbitmq-discuss