Rabbitmq and work queue

Rajitha Sandaruwan
2 min readJul 22, 2020

RabbitMQ is an open source multi-protocol messaging broker. Running rabbitmq-server starts a RabbitMQ node in the foreground. The node will display a startup banner and report when startup is complete. To shut down the server, use service management tools or rabbitmqctl.

Think of RabbitMQ as the back-end AJAX.

If an AJAX call is distributed computing for web browsers, then RabbitMQ is distributed computing for servers. Instead of dealing with HTTP requests that may be exposed to the internet, RabbitMQ is more often used for back-end services.

There are some key differences, of course. But this is less an analogy than it is a direct parallel — a different implementation of the same basic idea.

Some of these parallels and differences include the following:

table 1

So… What does RabbitMQ do?

  • Push work into background processes, freeing your web server up to handle more users
  • Scale the most frequently used parts of your system, without having to scale everything
  • Handle what would have been catastrophic crashes, with relative ease
  • Deal with seemingly impossible response time requirements for webhooks
  • Allow services to be written in different languages, on different platforms
  • … and so much more

What rabbitmq work queue?

RabbitMQ work queues are used to distribute time-consuming tasks among multiple workers. The main idea behind Work Queues (also called task queues) is to avoid doing a resource-intensive task immediately and having to wait for it to complete. A task can be scheduled to be done later.

Here is an example for this:

Receiver.java

figure 1:reciever.java

Console of receiver before receiving message

figure 2:reciever console before recieving message

sender.java

figure 3:sender.java

Console of sender after sending message

figure 4:sender console after sending message

Console of receiver after receiving message

figure 5:reciver console after recieving message

--

--