Monday, October 22, 2018

Asynchronous Messaging: RabbitMQ Introduction

RabbitMQ is considered today as a stable open source message broker implementation. It is considered by many as the natural evolution of JMS. What is brings to the table is the interoperability of disparate and heterogeneous parties. Indeed, a client in .Net for example can seamlessly exchange messages with a consumer on Java with minimal changes to any of these. It is worth noting that RabbitMQ is build with Erlang, the leader language in telecommunications systems within builtin support for fault tolerance.

RabbitMQ promotes the usage of AMQP (Advanced messaging queuing protocol) as the wire level protocol or network protocol for exchanging messages. It is a binary protocol that deals with the low level details of encoding and marshaling of message contents.

Architecturally, RabbitMQ provides the following advantages:

  • Reliability: Aside from being built with Erlan, RabbitMQ can be configured to persist messages, so that in case of a server crash, all messages can be restored. Additionally, producers and consumers can acknowledge proper reception/delivery of messages.
  • Customized routing: RabbitMQ supports different mechanisms for routing through the use of exchanges, it can for example provide point to point communication through direct routing, selective message delivery, similar to JMS message selectors, so that only events carrying a certain "routing key" get delivered to a queue.
  • Built in support for clustering and high availability: Many instances of RabbitMQ can be logically grouped under a single cluster in order to provide redundancy and ultimately high availability in the case of crashes.
  • Scripting and administration: RabbitMQ provides both a web based console for the purpose of monitoring and administration. In addition, it provides a command line interface to automate its administration through scripts.
  • Versatility: there is a plethora of clients for different platforms/technologies. 


Terminology

Since a picture is worth a thousand words, let's start with a high level schematic from RabbitMQ Documentation


  • Publisher: The party that is at the origin of the message to be sent.
  • Consumer: The destination party that expresses its interest in one or more messages.
  • Message Broker: The messaging solution in this case RabbitMQ. It is made of:
    • Exchanges: The abstraction that describes an intermediate endpoint/stage on the message broker where all messages are delivered first.
    • Queues: The intermediate endpoint where messages are sent from the exchange.
    • Route: Provides a routing strategy to define how and when messages on the exchange should be relayed to the queue. This usually takes the form of a routing key, and follows a binding definition.

In the next installment, we'll have a look at the different types of exchanges and various patterns for exchanging information over RabbitMQ.

No comments:

Functional Java: Hate the player not the game

We've all heard it over and over, Java 8 is not really functional programming. I admit that features like tail call optimization, closu...