How to create a Bootable USB Drive in Windows and Mac

There are a number of uses of a bootable USB drive, especially for booting your computer and removing the virus. Also, if your computer is not starting properly, then your hard drive may be faulty or…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Introduction to Message Queue with RabbitMQ example

This article explains message queuing, what it is, how to use it, and the benefits of using a message queue in an architecture.

A queue is a line of things waiting to be handled, starting at the beginning of the line and processing it in sequential order. A message queue is a queue of messages sent between applications. It includes a sequence of work objects that are waiting to be processed.

A message is the data transported between the sender and the receiver application.

In some use case when the system need to send request to another where the request should not be lost in this case we need a buffer to save the request and processed.This is where Message queue comes to action and the process is called Message Queuing.

In inter process communication Message queue is middleware implemented in servers with message broker softwares like RabbitMQ, ZeroMQ etc,.these handles the message queue for communications.Message queuing allows applications to communicate by sending messages to each other. The message queue provides temporary message storage when the destination program is busy or not connected.

Client applications that create messages and deliver them to the message queue are called producers. They produce messages that need to be processed by other Server or Client and put it in to the message queue.

Another application or System or Server that connects to the queue and gets the messages to be processed called a consumer. Messages placed onto the queue are stored until the consumer retrieves them.

In Message queuing on produces the message that to be processed and another one consumes that message.A message queue provides an asynchronous communications protocol, which is a system that puts a message onto a message queue and does not require an immediate response to continuing processing. Email is probably the best example of asynchronous communication. When an email is sent, the sender continues to process other things without needing an immediate response from the receiver. This way of handling messages decouples the producer from the consumer so that they do not need to interact with the message queue at the same time.

Through message queuing a system can be decoupled and scalable. Decoupling describes how much one piece of a system relies on another piece of the system. A decoupled system is achieved when two or more systems are able to communicate without being connected. Decoupling is often a sign of a computer system that is well structured because it is easier to maintain,If one process in a decoupled system fails to process messages from the queue, other messages can still be added to the queue and be processed when the system has recovered.

Instead of building one large application, it is beneficial to decouple different parts of your application and communicate between them asynchronously using message queues. This allows for different parts of the application to evolve independently, be written in different languages, and/or be maintained by separated development teams.

Producers add messages to the queue Consumers consumes the messages

In the above image as we see producers produce message and send to the message queue and consumers consumes that messages from queue. Producers don’t aware who is going to process the message it send and consumers don’t know where it comes from it just process the message other works are handled by middleware message brokers.

As we said it is scalable because when the request rate is increased by producers the consumers to process can be increased to the particular queue to consume the messages without delays. Message queue’s also can be increased according to the need.

Here we can see an example of message queue with RabbitMQ. Need to install RabbitMQ setup in your computer running. I took sample code from RabbitMQ website.I had tested some scenarios

After executing NewTask main method without Worker running we can notice in RabbitMQ dashboard had one message Ready to consume indicating in the graph as below.

NewTask send a message to message queue
RabbitMQ dashboard indicates one message ready to consume

2. After that i had executed Worker main method to receive and consume message in the queue.

After Worker executed it automatically consumed the message in the message queue which asynchronously done.

Add a comment

Related posts:

New Orleans and The Cloud That Changed My Life

Around August of 2018, I had an epiphany waiting for a bus in downtown Nashville. I was looking at the sky, watching a big, fluffy cloud go by. It a soft white where the sun touched it and a deep…

How Figma became our remote whiteboard

One of the ongoing challenges faced by any product design team is “managing the workbench”: first, selecting the right design applications in a crowded & highly-specialized field, then stitching them…

10 of the Untraditional Ways I Motivate Myself

You have so much work to do, projects to finish, and tasks to complete but you just can’t bring yourself to do them. There isn’t anything wrong with that and there isn’t anything wrong with you…