On this page

Message Queue Protocols

AMQP (RabbitMQ) uses exchange/queue/binding for intelligent routing, Kafka has consumers track offsets themselves for high throughput, and NATS pursues minimal latency with a minimalist text protocol. The three represent three design philosophies of messaging systems: smart broker, dumb broker, and minimal broker.

Overview

Message queues decouple producers and consumers—the sender does not wait for processing to complete, and the receiver consumes at its own pace. AMQP (2003) is known for its exchange/queue/binding model, with RabbitMQ being the most popular implementation. Kafka (2011) inverts the model: consumers track offsets themselves, and brokers do not push—making it better suited for high-throughput event streams. NATS excels in lightweight scenarios with its minimalist text protocol and minimal latency. The three represent three design philosophies of messaging systems: smart broker, dumb broker, and minimal broker.

AMQP 0-9-1

Model:
  Publisher → Exchange → (binding rules) → Queue → Consumer

Exchange types:
  direct:   routing key exact match → queue
  topic:    pattern match (stock.us.*) → multiple queues
  fanout:   broadcast to all bound queues

Ack:
  After each message is processed by the consumer → basic.ack(delivery_tag) → broker deletes it
  Unacknowledged messages: consumer disconnects → requeue

Prefetch (QoS):
  basic.qos(prefetch_count=1): sends only 1 uncompleted message at a time → fair distribution

Kafka Wire Protocol

Kafka is an append-only log, completely different from AMQP's broker-push model:

Topic → Partition 0: [offset 0][offset 1]...[offset N]
        Partition 1: [offset 0][offset 1]...[offset N]
        Partition 2: [offset 0][offset 1]...[offset N]

Consumer: tracks offsets itself, pulls (polls) → processes → commits offset

Wire protocol (TCP):
  ApiVersions → Metadata → Fetch → Produce → OffsetCommit
  Binary, length-prefixed frames

NATS

Minimalist text protocol:

PUB subject reply-to size\r\npayload\r\n
SUB subject queue-group sid\r\n

JetStream (persistence layer): adds stream/consumer on top of core NATS → Kafka-like features

Comparison

AMQPKafkaNATS
Modelbroker pushconsumer pullpub/sub + JetStream
PersistencedefaultdefaultJetStream
Throughput~50K msg/s~1M msg/s~1M msg/s
Latency~1ms~5ms~0.1ms

References

  • AMQP: rabbitmq.com/resources/specs/amqp0-9-1.pdf
  • Kafka: kafka.apache.org/protocol
  • NATS: docs.nats.io/reference/reference-protocols/

Keywords: AMQP, RabbitMQ, Kafka, partition, consumer group, offset, NATS, JetStream