RabbitMQ and things to know

Tram Ho

What is RabbitMQ?

For programmers, rabbitmq is very valuable, if there is no message broker system like rabbitmq, anytime need to push data between the components in the system, the programmer needs a direct connection. In fact, RabbitMQ is just a message broker using AMQP – Advanced Message Queue Protocol, it is programmed in Erlang language, besides that it provides programmers with an intermediary means to communicate between multiple cities. In this way, RabbitMQ will receive messages from different components in the system, storing data safely before reaching the destination.

The larger the system, the greater the level of message exchange between the components, thus increasing the complexity of programming. There was a time when programmers should focus only on the business logic of the application, and behind-the-scenes work should reuse existing solutions. Rabbitmq is also a very good solution in large system architectures.

Should we use RabbitMQ?

In a distributed system there will be many different components. If they want to be able to communicate with each other, they must know each other, but this makes it difficult to code. A component must know so much that it is difficult to maintain and debug. The solution here is that instead of direct links, causing the components to know each other, use an intermediary link through a message broker. With the participation of a message broker, producers will not know consumers. It just sends the message to the queues in the message broker. Consumer simply registers to receive messages from these queues.

Understandably, because producers talk to intermediate consumers via message broker, even though producers and consumers have differences in language, communication is still successful. Whether written in java, python, php or ruby ​​… then just need to satisfy the protocol with the message broker, then it is clear. Currently, rabbitmq has provided client libraries for many languages ​​already. This feature allows flexible system integration.

Types of Exchange in Rabbitmq

There are 5 types of Exchange: direct, topic, fanout, headers.

Direct Exchange

The function of Direct exchange is to push messages to the waiting queue based on routing key. This type of direct exchange is quite useful when you want to distinguish published messages for the same exchange by using a simple string identifier.

Fanout Exchange

The function of Fanout exchange will push the message to the entire queue attached to it. It is considered a copy of the message to all queues with any routing key. If registered, it will be ignored. This Exchange is useful when we need a data to be sent to many different devices with the same message but the treatment is different for each device and each location.

Topic Exchange

The exchange exchange will make a wildcard to attach the routing key to a routing pattern declared in binding. Consumer can subscribe to topics that interest him. The syntax used here is * and #.

Headers Exchange

An exchange header uses the message’s header properties to route. Exchange header is very similar to Topic Exchange, but it routes based on header values ​​instead of routing keys. A message is considered appropriate if the value of the header is equal to the value specified when binding.

Dead Letter Exchange

If no suitable queue is found for the message, the message will be automatically canceled. RabbitMQ provides an AMQP extension called “Dead Letter Exchange” – Provides functionality to capture messages that cannot be sent.

The salient features of RabbitMQ


For servers that need connections that are not too tight and highly reliable than clustering allows, RabbitMQ provides a link model that fits this requirement.

Flexible routing

Messages will be routed through exchange before being sent to the queue. RabbitMQ provides a number of built-in exchanges for typical logical routing. With more complex routing, you can link exchanges together or even write your own exchange types as a plugin.

Clustering / clustering

RabbitMQ has the function of grouping together, forming a single intermediary.


RabbitMQ supports a variety of features that allow you to reliably transact tasks, with longer retention times, delivery confirmations, publisher certifications, and high availability.

Queue is highly available

Queue can be replicated on a number of machines in a cluster, ensuring your messages are always safe even when a hardware failure occurs.

Multi protocol

RabbitMQ supports messaging through many different messaging protocols.

Diverse language applications

RabbitMQ has now been developed with a rich language system covering almost every language you can think of.

Management interface

With an easy-to-use management interface, RabbitMQ allows you to track and control every issue in an intermediary messaging program.

Plugin system

RabbitMQ supports a wide range of plugin extensions in many different forms, or you can also write these extensions yourself.

Tracing / Tracing

If your messaging system fails or is not working properly, RabbitMQ will assist with trace operations to help you understand how the system is working and what problems are arising.

Share the news now

Source : Viblo