What is RabbitMQ?
RabbitMQ is an open-source message broker that implements the message queue protocol, being able to exchange messages between publishers and listeners among different channels and routes.
Among RabbitMQ’s main features, find some important ones below, with a brief explanation of it
Message
A message is a key part of RabbitMQ communication. It moves through channels, from publisher to listeners, and can have any kind of information, from simple text to complex objects serialized.
Channel
Channel is a logical communication line between the publisher and the listeners. It stands on an existent connection and may transfer messages through different protocols.
Queue
A RabbitMQ queue works following FIFO pattern for storing messages between publishers and listeners.
Connection
A RabbitMQ connection is based on protocols, is the base for having channels running and, as its names say, connects the server to the client.
Consumer
RabbitMQ client, which is connected to a channel listening to its queues in order to read the messages published on it.
Publisher
RabbitMQ client, which is connected to a queue publishing messages to it.
Notification
Notifications are related to monitoring the service health and may be customized in order to alert based on metrics.
Dead letter
In RabbitMQ, the dead letters are used to store messages that were not able to be read by their listeners. It may not be read because the message was rejected by the listeners, or because the queue was full or due to the message expiration time.
Route
RabbitMQ routes are responsible to send the messages to their correct queues based on their routing keys and exchanges.
Virtual Host
Comparing with a SQL Server database, a RabbitMQ Virtual Host would be a SQL Server Database. Virtual Hosts have their own settings and are independent of others Virtual Hosts, they have their own channels, bindings, protocols, users, etc..
Exchange
RabbitMQ exchange is responsible for routing messages to their queues based on their attributes.
Bindings
A RabbitMQ binding works like a link from the queue to an exchange.
Main benefits of RabbitMQ usage
- Multi-platform communication, with messages being serialized/deserialized in common languages such as JSON;
- Async operations, not leaving services locked waiting for an answer;
- Open-Source, with a large community working to improve its features daily;
- Multi-language, with a wide range of languages accepted;
- Multi-protocol, with different types of protocols used to exchange messages.
Implementation Step by Step
In this sample, will be used a Web Api posting user locations in a RabbitMQ queue and a console application in a different solution reading and displaying this data.
Downloads required
- RabbitMQ Server and Erland(required for RabbitMQ)
https://www.rabbitmq.com/download.html - RabbitMQ client for .Net
https://www.rabbitmq.com/dotnet.html
https://www.nuget.org/packages/RabbitMQ.Client/
Default RabbitMQ configuration
- Endpoint address: http://localhost:15672/
- Login: guest
- Password: guest
- Windows Service Name: RabbitMQ
- Windows menu item to start the service: RabbitMQ Service – start
Downloads Source Code on GitHub
Be First to Comment