Main menu

Pages

RabbitMQ From High-level Prospective



RabbitMQ is a message broker that implements an advanced message queuing protocol (AMQP)

AMQP: standardizes messaging using Producers, Brokers, and Consumers

Messaging increases loose coupling and scalability

Main components: Producers, Consumers, Exchange, Queue, Binding key, Message

Core Concepts:
  • Producer emits messages to exchange
  • The consumer receives messages from the queue
  • Exchange compares routing key with Binding key
  • Binding connects an exchange with a queue using a binding key

Binding exchange with queue through binding key



Messages distribution depends on the exchange type

Exchange type

  • Default is nameless: send direct to queue name

  • Fanout: broadcast message to all queues

  • Direct: to specific queue if routing key = binding key 

  • Topic: partial match if the binding key contains routing i.e (binding key ="red. green" and routing key ="red.*"

  • Headers: message header instead of routing key

Queue characteristics:

  • Name

  • Durable (option allows the queue to survive even the RabbitMQ is down and restarted)

  • Exclusive (used only by one connection (current connection) and will be deleted when that connection closes from the consumer side)

  • Auto-delete (queue that has had at least one consumer is deleted when the last consumer unsubscribed)

  • Arguments (optional; used by plugins and broker-specific features such as message TTL, queue length limit, etc)
  • Transient: is the opposite of Durable as it is deleted if the broker restarted as it stored including messages in memory not like Durable stored in desk

Queue Types:

  • Distributed and Replicated Queues

            - Queue can be classic or replicated in multiple clusters for load-balancing purposes

  • Temporary Queues
              - Instead of deleting the queues you have created before you can declare or configure the queue to be temporary in 3 ways :
      1. Exclusive queue 
      2. TTLS (time to live)
      3. Auto-delete queue

  • Exclusive Queues

                - Get deleted by ending the connection after consuming

  • Server-named Queues
                - Broker or rabbitMQ can generate a unique name for the queue by sending an empty string in the queue name argument as the queue name is required


Note:

- when you need to name the queue it should not start with "amq" as it reserved for internal use by rabbitmq or broker


Resources :

Comments