Skip to main content

RabbitMQ

RabbitMQ speaks AMQP 0-9-1, a binary, frame-based messaging protocol.

Note that AMQP 1.0 is a different protocol despite the shared name, with different framing and a different model. DataStream speaks it only through the Azure Service Bus and Event Hubs targets; nothing on this page applies to those.

Connection

A connection opens with an 8-byte protocol header, which is the first thing on the wire:

"AMQP" 0x00 0x00 0x09 0x01

The server replies with connection.start and the two sides then exchange start-ok, tune, tune-ok, open and open-ok. The tuning step negotiates the maximum frame size, the channel limit and the heartbeat interval.

There is no in-band upgrade to TLS—AMQP 0-9-1 has no STARTTLS. A TLS connection is established before the protocol header is sent, conventionally on port 5671 rather than 5672.

Binary Layout

FieldInternal NameDescriptionType / FormatExample / Values
Typeframe_typeType of frameuint81 = Method, 2 = Header, 3 = Body, 8 = Heartbeat
Channelchannel_idChannel numberuint16e.g. 1, 0 for connection-level
Sizeframe_sizePayload size in bytesuint32e.g. 0x00000014
PayloadpayloadFrame-specific dataBinaryDepends on frame_type
Endframe_endFrame terminatoruint8Always 0xCE

Frame Types

TypeNamePurpose
1MethodAMQP method calls (open, close, publish, etc.)
2HeaderContent header with properties
3BodyMessage content data
8HeartbeatKeep-alive signal

These four are the complete set defined by AMQP 0-9-1.

Publishing a message takes three frames in sequence on the same channel: a Method frame carrying basic.publish, a Header frame carrying the content properties and body size, and one or more Body frames carrying the payload.

Exchange Types

TypeRouting
directTo queues whose binding key equals the routing key
fanoutTo every bound queue, ignoring the routing key
topicTo queues whose binding pattern matches the routing key
x-customRouting supplied by a broker plugin

Authentication

Credentials are exchanged during connection.start-ok. Two SASL mechanisms are supported:

MechanismDescription
plainUsername and password, as a single NUL-separated string
amqplainUsername and password, as an AMQP field table

external and the challenge-response mechanisms are not supported.