This document builds on the high-level informative document about event-driven architecture.
This is a normative document for usage and operation of RabbitMQ.
Our queue messaging solution works with AWS with SQS and SNS.
SQS is a queue solution and SNS is notification service that delivers messages to multiple queues.
-
To a queue - When publishing messages to a queue only a single subscriber can consume that message. Transport is entirely handled by SQS. (Direct)
-
To a topic - A message (or an event) is published to a topic and delivered to a multiple queues subscribed to it. Transport is done first by SNS and then zero or more SQS queues. (Fanout)
RMQ uses a two component solution analogous to SNS and SQS, where every message is published to an exchange that delivers it to individual queues.
Every message delivered to a queue gets consumed once by a single subscriber, meaning if multiple subscribers are consuming messages from a queue, only a one of them will see a given message.
Publishers in RMQ don’t publish messages directly to queues, but rather to exchanges that then route messages to queues based on rules determined by the exchange type and queue configuration.
-
Direct - Messages get delivered directly to a queue based on the routing key, docs
-
if no exchange is specified the messages are delivered directly to a queue with the same name as the routing key.
-
If an exchange is specified, message is delivered to all queues subscribed to a routing key.
-
-
Fanout - Messages are published to an exchange and delivered to all queues subscribed to it. Docs
-
Topics - Topic exchanges route messages to one or many queues based on matching between a message routing key and the pattern that was used to bind a queue to an exchange. docs
-
Header - A headers exchange is designed for routing on multiple attributes that are more easily expressed as message headers than a routing key. Headers exchanges ignore the routing key attribute. Instead, the attributes used for routing are taken from the headers attribute. Docs
RMQ enables very sophisticated routing of messages, but of the purposes of an alternative to our existing use cases, the direct exchanges and fanout exchanges are sufficient.