Overview

  • RabbitMQ message broker that implements Advanced Message Queuing Protocol (AMQP). AMQP standardizes messaging using Producers, Broker and Consumers.
  • Written in Erlang
  • Provides reliability, routing, clustering and high availability, management web interface, command line interface
  • Platform agnostic and supports many client libraries in different programming languages

AMQP

In AMPQ a producer produces a message and sends it to an exchange. The exchange forwards the message to a queue. The consumer will than pick up a message and consume it.

Core Concepts

  • Producer emits message to exchange.
  • Consumer receives messages from queue using binding key
  • Exchange compares routing key with binding key.
  • Message distribution depends on exchange type
  • Exchange types: fanout, direct, topic, and headers.

Exchange Attributes

  • Name – The name of the exchange
  • Durability – persisting the messages to disk
  • Auto-Delete – Delete message when not needed
  • Arguments – These are message broker-dependent

Exchange Types

  • Fanout – sends every message to every queue it knows about.
  • Direct – sends message to routing queue based on key.
  • Topic – sends message based on partial match to routing queue
  • Header – Message header is used instead of routing key
  • Default (nameless) – uses routing queue name as key instead of routing key
Good for distributing against multiple worker processes in round robin manner
Broadcast to all queues

Good for broadcasting messages. Multiple consumers choosing messages to receive.


Management Portal

  • By default hosted at http://localhost:15672
  • username guest / password guest

Tips

  1. “A happy rabbit is an empty rabbit” – aim to keep queue lengths short
  2. The queue is rabbit’s basic unit of concurrency
  3. The “Transfer of Responsibility” Notion – know who is responsible for a message at any given point
  4. Consumers should eat not nibble – when possible consumers should take a batch of messages instead of one
  5. Know costs of guarantees and don’t overpay unnecessarily

Resources