The Concept RabbitMQ. What’s it ?
Introduction
RabbitMQ is the most widely deployed open source message broker. It understands AMQP (Advanced Message Queuing Protocol), but is also able to be used with other popular messaging solutions like MQTT. It is highly available, fault tolerant and scalable. It is implemented in Erlang OTP, a technology tailored for building stabe, reliable, fault tolerant and highly scalable systems which possess native capabilities of handling very large numbers of concurrent operations, such as is the case with RabbitMQ and other systems like WhatsApp, MongooseIM, to mention a few.
RabbitMQ support multiple protocols, here is the protocol that RabbitMQ support:
AMQP — is the core protocol for RabbitMQ. It’s a Message Broker. But it also supports STORM, MQTT and HTTP through the use of plugins.
HTTP — you’re probably familiar with this one. This is Hypertext Transfer Protocol. It is not a messaging protocol, but management plugins in RabbitMQ use HTTP to send and receive messages.
STOMP — a simple text based messaging protocol
MQTT — is a binary protocol known for its lightweight messaging
what does RabbitMQ do ?
RabbitMQ allows to solve a new class of problems in today’s “web scale” world.
- 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
The benefits that you get from RabbitMQ are really the benefits of distributed computing and messaging.
When and why should you use RabbitMQ ?
Message Queuing
Message queuing facilitates effective communication between applications by sending messages. It also serves as a temporary shelter for messages by storing them while the destination application is busy or not connected.
Message queueing allows web servers to respond to requests quickly instead of being forced to perform resource-heavy procedures on the spot that may delay response time. Message queueing is also good when you want to distribute a message to multiple consumers or to balance loads between workers.
RabbitMQ comes with four useful exchange types that cover most of the use-cases for messaging.
- Direct exchange — This will deliver the incoming message to any queue which is binding key exactly matches the routing key of the message. If you bind the queues with the queue name as routing keys, then you can think about it as a one-to-one message delivery. It is simple to deliver the same message to multiple queues by using the binding keys for multiple queues.
- Topic exchange- — This will deliver the incoming message to any queue whose wild card binding key matches the routing key of the published message. Binding keys can contain wild-card matching criteria for a compound routing key. This enables us to write simple services where the logic is well contained,
- Fanout exchange — Some messages need to be delivered to all queues, this is where a fanout exchange can be used instead of writing an elaborate multicast logic in the application. With a RabbitMQ fanout exchange, each service binds the appropriate queue to the exchange without need to specify a binding key, and it all happens automatically. If a binding key is specified, the fanout exchange will simply ignore it and still route/broadcast messages to all queues bound to it.
- Headers exchange — This exchange leverages the structure of AMQP messages and is capable of complex routing based on the headers (including custom ones) of the AMQP message. Headers are metadata attached to each message sent via AMQP.
Message flow in RabbitMQ
There are three AMQP entities in RabbitMQ:
· Exchange
· Binding
· Queues
Now that we’ve got the basic theory out of the way, Let’s look at the on implementing RabbitMQ.
Requirement-— Print a sample message using RabbitMQ.
Sender Program
Receiver Pragram
Afer executing receiver ,
URL to open RabbitMQ — http://localhost:15672/
Thank You…!