Message Queues

Chamod Malintha
3 min readJul 22, 2020

RabbitMQ — Work Queue

RabbitMQ is can be defined as an open-source message queuing application or a message broker. Which consists of functionalities like connecting between applications, transfer messages to consumers from queues etc. In here we consider messages as which includes information it could be a simple text message or and complex one. Message queues are loaded with messages and RabbitMQ is the application that handling all the traffic and gradually passing all the messages to the relevant consumers. RabbitMQ connects in between web apps most commonly. It helps to balance the load and reduce the delivery time for web servers.

https://images.app.goo.gl/BUKgXHwCCzMgMyUw5

In RabbitMQ architecture we can see that it consists of three parts those are producer, queue, and consumer. An application that acts as a client is a producer while the consumer is at the retriever’s end. At times the same software act as both. Most of the time RabbitMQ is used when an application has multiple consumers with the requirement of distributing messages efficiently between them. RabbitMQ routes the messages from the queue to consumers after the producer publishes the message to the queue. This queuing mechanism helps to decouple applications and those can act independently in different programming languages as well.

I tested the sample work queue code given in the official RabbitMQ GitHub repository. The reference link is https://github.com/rabbitmq/rabbitmq-tutorials.

I downloaded the java-maven example code for the work queue and imported the project to the Eclipse IDE. Once I imported, I checked whether the dependency is available for java AMQP client which is shown below.

dependency

RabbitMQ and Erlang which is a required programming language and runtime environment for this are already downloaded and installed beforehand. Erlang is supporting for concurrency, distribution, and fault tolerance.

Once the RabbitMQ service is started we can enable management UI in port http://localhost:15672/ and also we can see other ports that are listening from the command line. Then I started two worker nodes because we are executing the work queue. Then send messages to those through RabbitMQ using another shell by running “NewTask.js”. We can clearly see that the messages are sent to worker nodes in a distributed way.

Executed worker in two consoles
Tasks are produced to the Queue
Running consumers
Consumers successfully receiving messages from the queue
RabbitMQ management UI display

--

--

Chamod Malintha

Software Engineer | BSc. (Hons.) in Software Engineering | University of Kelaniya, Sri Lanka