RabbitMQ - Widely Deployed Message Broker

Mar 07, 2021reviewsmessagingtools

RabbitMQ is one of the most popular open source message brokers. It is lightweight, open-source, easy to deploy on premises and in the cloud, supports multiple messaging protocols, and can be deployed in distributed and federated configurations to meet high-scale, high-availability requirements.

Getting Started

RabbitMQ ships in a state where it can be used straight away in simple cases such as development and QA environments - just start the server, enable the necessary plugins and it’s ready to go.

RabbitMQ is officially supported on a number of operating systems and has several official client libraries. In addition, the RabbitMQ community has created numerous clients, adaptors and tools that we list here for your convenience.

Under the Hood

RabbitMQ is a messaging broker so it relies on following concepts: Queues, Publishers, Consusmers, Messaging Protocols, Priority Queues.

Applications interact with RabbitMQ using client libraries. There are client libraries available for many programming languages and platforms. Each protocol has its own set of client libraries. Most client libraries are open source.

All protocols supported by RabbitMQ are TCP-based and assume long-lived connections (a new connection is not opened per protocol operation) for efficiency. One client library connection uses a single TCP connection. In order for a client to successfully connect, target RabbitMQ node must allow for connections on a certain protocol-specific port.

After a client connects and successfully authenticates with a RabbitMQ node, it can publish and consume messages, define topology and perform other operations that are provided in the protocol and supported both by the client library and the target RabbitMQ node.

Since connections are meant to be long-lived, clients usually consume messages by registering a subscription and having messages delivered (pushed) to them instead of polling.

When a connection is no longer necessary, applications must close them to conserve resources. Apps that fail to do it run the risk of eventually exhausting its target node of resources.

Why use RabbitMQ

RabbitMQ is a solid, general-purpose message broker supports several protocols, can handle high throughput, often used to handle background jobs or long-running task. RabbitMQ is also used between microservices, where it serves as a means of communicating between applications, avoiding bottlenecks passing messages.

Multiple messaging protocols: RabbitMQ supports several messaging protocols, directly (AMQP 0-9-1) and through the use of plugins (STOMP, MQTT, AMQP 1.0).

  • AMQP 0-9-1 and extentions: A binary messaging protocol and semantic framework for microservices and enterprise messaging.
  • STOMP: A text-based messaging protocol emphasising (protocol) simplicity
  • MQTT: A binary protocol emphasising lightweight publish subscribe messaging, targetted towards clients in constrained devices.
  • AMQP 1.0: Despite the name, AMQP 1.0 is a radically different protocol from AMQP 0-9-1 / 0-9 / 0-8, sharing essentially nothing at the wire level.

Transmit over HTTP: While HTTP is not really a messaging protocol. However, RabbitMQ can transmit messages over HTTP using plugins and WebSockets.

Message Acknowledgement: To make sure a message is never lost, RabbitMQ supports message acknowledgements. An acknowledgement is sent back by the consumer to tell RabbitMQ that a particular message has been received, processed and that RabbitMQ is free to delete it. If a consumer dies (its channel is closed, connection is closed, or TCP connection is lost) without sending an ack, RabbitMQ will understand that a message wasn’t processed fully and will re-queue it.

Reliability: RabbitMQ offers a variety of features to let you trade off performance with reliability, including persistence, delivery acknowledgements, publisher confirms, and high availability.

Flexible Routing: Messages are routed through exchanges before arriving at queues. RabbitMQ features several built-in exchange types for typical routing logic. For more complex routing you can bind exchanges together or even write your own exchange type as a plugin.

Clustering: Several RabbitMQ servers on a local network can be clustered together, forming a single logical broker.

Federation: For servers that need to be more loosely and unreliably connected than clustering allows, RabbitMQ offers a federation model.

Management UI: RabbitMQ ships with an easy-to use management UI that allows you to monitor and control every aspect of your message broker.

Summary

Messaging enables software applications to connect and scale. Applications can connect to each other, as components of a larger application, or to user devices and data. Messaging is asynchronous, decoupling applications by separating sending and receiving data.

RabbitMQ is a messaging broker - an intermediary for messaging. It gives your applications a common platform to send and receive messages, and your messages a safe place to live until received.

In general, if you want a simple traditional pub-sub message broker, the obvious choice is RabbitMQ, as it will most probably scale more than you will ever need it to scale.