RabbitMQ Concepts

What is RabbitMQ and when should I use it, giving the basics of rabbitmq and its functionalities like exchange, bindings, and queues.

Today we have things like smart lamps, smart lockers, smart fridge and so on...

The internet of things a.k.a IoT, brought a facilitation on our day to day life, so you might have wonder "how this thing works?"

Then RabbitMQ comes as a message broker, a message broker is nothing less than an intermediary for messaging, supporting different message protocols. Advanced Message Queuing Protocol (AMQP) and has since been extended with a plug-in architecture to support Streaming Text Oriented Messaging Protocol (STOMP), MQ Telemetry Transport (MQTT), and other protocols.

Image from https://www.cloudamqp.com/blog/part1-rabbitmq-for-beginners-what-is-rabbitmq.html

As you can see in the image above, it's simple we always have a consumer and a producer (working the same way as Netflix does, you have a subscription, with the subscription you can watch movies).

Exchange is an agent to route messages to a queue, which can be:

Direct: The message will only reach the queue if there's a routing key linking both.
Topic: The message goes by a routing pattern, we can think as a tree node, for example

let's suppose we have 3 houses and I want to send different information to these houses, I will use

house_1

house_2

house_3

if we want to update the lights and oven on house 2 we will use house2.lights, house2.oven and if we want to add or update anything on another house we follow the same concept, then the queue will be matching the pattern that you are sending.

Fanout: The message will be sent to all queues bound to the exchange

Here it follows the same way we subscribe to an exchange which a producer will send the queue and we consumers will be actively listening to it and when we receive we can do something on our end.

Comments