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 through the rabbitmq and amqp devices and targets when they set protocol: "1.0", through the amazonmq device and target (always on the activemq engine, and with protocol: "1.0" on rabbitmq), and through the Azure Service Bus and Event Hubs targets. This page describes AMQP 0-9-1 only; nothing on it applies to an AMQP 1.0 connection.

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
headersTo queues whose binding arguments match the message headers, ignoring the routing key
x-…Routing supplied by a broker plugin's type, such as x-consistent-hash

Authentication​

The SASL mechanism is selected during connection.start-ok, where plain and amqplain also send their credentials. Three SASL mechanisms are supported:

MechanismDescription
plainUsername and password, as a single NUL-separated string
amqplainUsername and password, as an AMQP field table
externalThe client certificate presented during the TLS handshake authenticates the connection (RabbitMQ's rabbitmq_auth_mechanism_ssl plugin). RabbitMQ maps the certificate's identity to the user name — its subject DN by default, or the common name or a subject alternative name that ssl_cert_login_from selects — and that user must exist

The challenge-response mechanisms are not supported.