As detailed in our previous blog post on queueing, the Advanced Message Queuing Protocol(AMQP) is a standardised interface that our technology of choice of which RabbitMQ is one implementation. Here we will discuss some of the key concepts and features of RabbitMQ that we have found useful at Esendex.
Key Concepts
AMQP has a number of elements that intrinsic to its design, which include:
- Client – This is hosted within your software and communicate with a broker in order to achieve tasks such as sending a message or receiving a messages.
- Publisher – This is the name for the parts of your software sending messages to the queue.
- Consumer – This is the name for the parts of your software receiving messages from the queue.
- Broker – A service which operates exchanges and queues and manages connections, this covers the bulk of RabbitMQ’s behaviour.
- Exchange – This is a part of the broker and its job is to route the message to a queue, there are different types of exchange which will behave differently according to how you would like your queues to behave.
- Queues – The storage mechanism for messages, these can exist in memory or on disk. They can receive messages from multiple exchanges and can be accessed by multiple consumers.
An important thing to remember when working with RabbitMQ is that publishing a message to a broker does not mean that the message will be directly published to a queue like some queueing technologies. Instead, when a message is pushed to a broker it is published to an exchange. It is a Publisher’s job to decide which exchange it would like to send messages to, just as it is a Consumer’s job to decide which queues to read from.
Publishers should only care about exchanges and Consumers should only care about queues. This, coupled with the fact that routing messages is handled by the exchange, means that Publishers and Consumers do not depend on each other.
Exchange Types
Here are some of the basic, but commonly useful exchange types
- Direct Exchange – The more traditional queueing scenario this exchange will route a copy of each message it receives to all queues bound to it.
- Topic Exchange – In this case, messages are routed to queues based on a routing key
- Fanout Exchange – Messages are routed to each of the bound queues in turn, according to a Round Robin pattern.
You can implement your own client capable of acting as a Publisher or Consumer by using one of the numerous SDKs, there will most likely be one available in your language of your choice.
There are more queueing configurations available than we cover here, if you are interested in finding out more about how these entities can interact to produce a messaging pattern that is useful to you then head over to the AMQP Concepts page on RabbitMQ’s official site.
To find out more about RabbitMQ see other blog posts in this series or visit the RabbitMQ website and development blog.