Skip to content

RobustMQ AMQP Protocol Support

This document lists the AMQP 0.9.1 protocol methods that RobustMQ needs to support as an AMQP Broker, along with their priority and description.

References:


Protocol Basics

AMQP 0.9.1 runs over TCP and uses a frame-based transport. Each frame consists of a type, channel number, payload length, payload, and a frame-end byte (0xCE).

  • Connection flow img

  • Produce & Consume flow

img

  • Broker internal logic img

Frame Types

Frame TypeCodeDescription
Method Frame1Control commands (all Class/Method pairs)
Content Header Frame2Message properties (content-type, delivery-mode, headers, etc.)
Content Body Frame3Message payload (may be split across multiple frames)
Heartbeat Frame8Keep-alive heartbeat

Message publishing and delivery each require a Method + Content Header + Content Body frame sequence.


1. Connection Class (Required)

Connection-level handshake, all on channel=0. The broker initiates start, secure, tune, and close, and processes the client's responses.

Class.MethodCodeDirectionDescriptionSupported
connection.start10.10S→CBroker initiates handshake, advertises supported SASL mechanisms and locales
connection.start-ok10.11C→SClient selects SASL mechanism and sends authentication response
connection.secure10.20S→CBroker sends SASL challenge (for multi-step mechanisms)
connection.secure-ok10.21C→SClient responds to SASL challenge
connection.tune10.30S→CBroker proposes channel-max, frame-max, heartbeat parameters
connection.tune-ok10.31C→SClient confirms connection parameters
connection.open10.40C→SClient opens a virtual host
connection.open-ok10.41S→CBroker confirms vhost connection
connection.close10.50BothEither side initiates connection close (with error code)
connection.close-ok10.51BothConfirms close

2. Channel Class (Required)

Multiple channels can be multiplexed over a single TCP connection, each independently handling message flow.

Class.MethodCodeDirectionDescriptionSupported
channel.open20.10C→SClient opens a channel
channel.open-ok20.11S→CBroker confirms channel is open
channel.flow20.20BothPause or resume message flow (back-pressure control)
channel.flow-ok20.21BothConfirms flow command
channel.close20.40BothClose channel (with error code)
channel.close-ok20.41BothConfirms close

3. Exchange Class (Required)

Exchanges are the core of message routing, supporting direct, fanout, topic, and headers types.

Class.MethodCodeDirectionDescriptionSupported
exchange.declare40.10C→SCreate or verify an exchange (type/passive/durable/no-wait)
exchange.declare-ok40.11S→CConfirms creation
exchange.delete40.20C→SDelete an exchange (if-unused option)
exchange.delete-ok40.21S→CConfirms deletion

4. Queue Class (Required)

Class.MethodCodeDirectionDescriptionSupported
queue.declare50.10C→SCreate or verify a queue (passive/durable/exclusive/auto-delete)
queue.declare-ok50.11S→CConfirms creation, returns queue name, message count, consumer count
queue.bind50.20C→SBind a queue to an exchange (with routing-key)
queue.bind-ok50.21S→CConfirms binding
queue.unbind50.50C→SRemove a queue binding from an exchange
queue.unbind-ok50.51S→CConfirms unbinding
queue.purge50.30C→SRemove all unacknowledged messages from a queue
queue.purge-ok50.31S→CConfirms purge, returns message count removed
queue.delete50.40C→SDelete a queue (if-unused / if-empty options)
queue.delete-ok50.41S→CConfirms deletion, returns message count removed

5. Basic Class (Required)

The Basic class is the core of AMQP 0.9.1, covering message publishing, delivery, and acknowledgment.

5.1 Consumer Management

Class.MethodCodeDirectionDescriptionSupported
basic.qos60.10C→SSet prefetch (prefetch-size, prefetch-count, global)
basic.qos-ok60.11S→CConfirms QoS settings
basic.consume60.20C→SRegister a consumer, start push-mode delivery (no-local/no-ack/exclusive)
basic.consume-ok60.21S→CReturns consumer-tag
basic.cancel60.30C→SCancel a consumer
basic.cancel-ok60.31S→CConfirms cancellation

5.2 Message Publishing

Class.MethodCodeDirectionDescriptionSupported
basic.publish60.40C→SPublish a message (exchange, routing-key, mandatory, immediate), followed by Content Header + Body frames
basic.return60.50S→CReturn an unroutable message to publisher (triggered by mandatory/immediate flags)

5.3 Message Delivery

Class.MethodCodeDirectionDescriptionSupported
basic.deliver60.60S→CBroker pushes message to consumer (push mode), followed by Content Header + Body frames
basic.get60.70C→SSynchronously pull one message (pull mode)
basic.get-ok60.71S→CReturns message, followed by Content Header + Body frames
basic.get-empty60.72S→CResponse when queue is empty

5.4 Message Acknowledgment

Class.MethodCodeDirectionDescriptionSupported
basic.ack60.80C→SAcknowledge message(s) as processed (multiple flag for batch ack)
basic.reject60.90C→SReject a message (requeue=true to requeue, false to discard)
basic.recover60.110C→SAsk broker to redeliver all unacknowledged messages
basic.recover-ok60.111S→CConfirms recover

6. Tx Class (Optional, Local Transactions)

Class.MethodCodeDirectionDescriptionSupported
tx.select90.10C→SEnable transaction mode
tx.select-ok90.11S→CConfirms transaction mode enabled
tx.commit90.20C→SCommit transaction (publish + ack atomically)
tx.commit-ok90.21S→CConfirms commit
tx.rollback90.30C→SRoll back transaction
tx.rollback-ok90.31S→CConfirms rollback

7. RabbitMQ Extensions (Optional)

The following are RabbitMQ private extensions to AMQP 0.9.1, not part of the standard spec, but widely used by mainstream clients:

ExtensionDescriptionSupported
basic.nackBatch reject messages (standard reject only handles one at a time)
confirm.select / confirm.select-okPublisher Confirm mode: broker sends ack/nack for each published message
exchange.bind / exchange.bind-okExchange-to-Exchange binding
exchange.unbind / exchange.unbind-okRemove Exchange-to-Exchange binding

Publisher Confirm is an almost universally required reliability feature in production — recommended to implement alongside basic.publish.


Core Broker Business Logic

About half of the 53 methods in AMQP 0.9.1 are *-ok acknowledgment replies that the broker constructs and returns directly. The methods requiring real business logic are:

CapabilityMethods InvolvedDescription
Authenticationconnection.start / start-ok / secure / secure-okSASL handshake, supporting PLAIN and AMQPLAIN mechanisms
Routingexchange.declare + queue.bind + basic.publishpublish → exchange → binding → queue matching; supports direct/fanout/topic/headers
Push Deliverybasic.consume + basic.deliverMaintain consumer registry, respect prefetch window, push messages to consumers
Acknowledgmentbasic.ack / reject / nack / recoverDrive message state transitions (unacked → acked / requeued / dead-lettered)
Transactionstx.select / commit / rollbackAtomicity guarantee for publish and ack operations (optional)

Implementation Roadmap

Phase 1: Standard Client Compatibility

After implementing the following methods, standard AMQP clients (pika, amqplib, etc.) can send and receive messages:

text
connection: start → start-ok → tune → tune-ok → open → open-ok
channel: open → open-ok
exchange: declare → declare-ok
queue: declare → declare-ok → bind → bind-ok
basic: publish(+Header+Body) → deliver(+Header+Body)
basic: consume → consume-ok → ack
connection/channel: close → close-ok

Phase 2: Full Message Semantics

Add on top of Phase 1:

  • basic.qos (prefetch flow control)
  • basic.reject / basic.recover (message redelivery)
  • basic.get / get-ok / get-empty (pull mode)
  • basic.return (mandatory message return)
  • queue.purge / delete, exchange.delete

Phase 3: Reliability & Transactions

  • Publisher Confirm (confirm.select + basic.ack/nack)
  • Tx transactions (tx.select / commit / rollback)
  • basic.nack (batch reject)
  • Exchange-to-Exchange binding