RabbitMQ is an open-source message broker. In short, it manages our queues (asynchronous operations).
The broker’s server is written in Erlang, while the API for clients is available in many programming languages, e.g. PHP, java, c #, swift and more.
Synchronous and asynchronous operations
Synchronous operations are operations (also known as blocking operations) that stop a thread until it is executed. Simply put, these are real-time operations.
Asynchronous operations mean that the application that uses them only reacts (starts doing something) when it knows that the necessary data has been transferred.
A few examples of situations when it is worth using asynchronicity
- Diverse traffic on the site
- Willingness to reduce the resources used by a given functionality
- When we perform some business logic that can be performed after the user’s request, eg matching proposed advertisements
- Functionalities that take a long time to perform
Queue handling by RabbitMQ
Producer
A producer is a system that sends a job to Rabbit. The system may produce multiple jobs, or multiple systems may submit jobs to one queuing system.
Exchange
When tasks go to Rabbit, they are assigned to a specific messaging center. The producer assigns jobs to the specified exchange by specifying its name when sending the job.
Binding
Binding is a mechanism for assigning items in the message center to a specific queue. The division into queues is quite important because we will be dealing with generating reports differently than sending a newsletter.
Consumer
The consumer handles tasks from specific queues.
RabbitMQ management
RabbitMQ management is not available by default and to enable access we must run the command:
rabbitmq-plugins enable rabbitmq_management
After unblocking access, we can log in to the panel at: http://localhost:15672
Leave a Reply