Rabbit MQ is the most popular open source and cross platform message broker (messages queue software) that accepts, stores and forward messages. It implements Advanced Messaging Queuing Protocol ( AMQP).
Decoupling of software components is one of the major part in software design . One way to achieve decoupling is building messaging applications which can be achieved by "RabbitMQ", way to exchange data between different applications.
Why and when to use?
Most organisations nowadays perform multiple tasks in single application like sending mail, SMS that can create heavy load on the application, so if we separate the tasks, will get more space / memory to serve more requests. By using RabbitMQ we can reduce the load on application.
Let's take a quick look of how messaging works.
We have two kinds of applications interacting with the messaging system :
The person/program that send messages to the broker.
>> Consumer :
Program that receives messages from the broker.
Usually these are the two different applications running on different machines and RabbitMQ works as a middle ware between the two applications.
Sender Queue Consumer
Using RabbitMQ with Visual Studio :
1. Installation :
Before we start, we need to install Erlang and RabbitMQ in the system. After RabbitMQ is been installed in the system we need RabbitMQ.net Client service to connect with RabbitMQ service. We can install RabbitMQ client via Nuget Package Manager in Visual studio.
2. Build .net application using RabbitMQ:
Create a Windows Application in visual studio . Install RabbitMQ client using Nuget package Manager.
Now let's start with the messaging windows application :
>> After designing the form, click on submit button and write the following code to send the message using Rabbit MQ client over the queue.
Hostname : It will be the IP Address on which the RabbitMQ service is running, by default it takes localhost.
>> It will send the message to RabbitMQ client (Sender) :
>> As soon as we send the message, it will be visible into RabbitMQ queue.
The above image shows our message is been queued up.
We can find the message is sent by the sender.
This message is not yet received by Receiver as we need to manage receiver end.