RabbitMQ, What is that?

RabbitMQ is one part of Message Broker that implemented Advance Message Queue Protocol (AMQP), that help your application to communicate each other, when you extends your application scale.

https://www.cloudamqp.com/img/blog/exchanges-topic-fanout-direct.png

Before I talk about RabbitMQ, I want to make sure that all of you know about 2 ways to communicate between micro-services. They are Point to Point (P2P)/Synchronous Communication, and Publish-Subscribe (Pub-Sub)/Asynchronous Communication. What is the differences between those two?
P2P as it’s called Synchronous Communication, we know that one app will directly communicate to other app, using HTTP protocol, which is the app does require immediate get response directly from the server.
Pub-Sub as it’s called asynchronous communication, we know that it’s does not required immediate response from the server, and the message that sent will be placed to a message queue (or known as Event Queue in Enterprise Messaging System).

RabbitMQ also called as middleware build using Erlang, due it can be both micro-services and an app. RabbitMQ support multiple protocols, here is the protocol that RabbitMQ support:
- AMQP
- HTTP
- STOMP
- MQTT

How RabbitMQ work?

Exchange is an algorithm that decide which queue that will store the message
(get message from producer, include in queue of consumer). Each consumer get it’s own Queue based on logic that you use, there are 4 type of logic that you can use in Exchange:
- Direct Exchange: Will be direct to queue based on a message routing key
- Fanout Exchange: Will publish to all queues that have same routing key
- Topic Exchange: Will publish to all queue that have same routing key and routing pattern specified in the binding
- Headers Exchange: Header means header in sending a file http, like when you send Image the header is ‘image/*’

Why do we need to use RabbitMQ?

Decouple: What means by decoupling is separate the core components of the application. This is what any application that implement micro-services wanted. Because their application will be maintainable and improve it’s quality of Single Responsibility Principle.

Flexibility: Because the application has been decoupled, so the application will be flexible enough for being develop to the next phase. But no only that flexible, because if you are using RabbitMQ, you will be able to connect 2 different apps/service that written by different app, these application will talk to each other by the help of a “translator” which is MOM.

Another benefit of using RabbitMQ:
- Highly Available Queue
- Multi-Protocol
- Many Client
- Clustering
- Management UI
- Tracing (Using dashboard can trace support)
- Plugin System (Extend core broker functionality in a variety of ways)

RabbitMQ vs Kafka

There is another message broker I know, it’s Kafka. What is the differences between RabbitMQ and Kafka? As far as I know, this is the basic differences between RabbitMQ and Kafka:

Kafka -> Dumb Broker, Smart Consumer to read its buffer
RabbitMQ -> Smart Broker, Dumb Consumer to read its buffer

Maybe the detail will be deliver on different post…

What Next?

Trying to learn what is producer, consumer, message, exchange algorithm, differences between RabbitMQ and Kafka.

Source:
https://www.rabbitmq.com
https://dzone.com/articles/all-you-need-to-know-about-asyncronous-messaging-u
Thanks to Marthin Pasaribu, Rizki Maulana and Andi Pangeran for the information.