Exchanges
What is an Exchange
Take messages from publishers and route those messages to queues, streams or other exchanges.
Types
Determines how messages are routed to there destinations.
Fanout
Every message is published to every destination.
Topic
Uses pattern matching on the routing key to determine the destination.
The routing key is split into segments by a . delimiter.
* - matches on exactly 1 segment
# - matches on 0-to-many segments
Examples
audit.events.#
matches - audit.events, audit.events.thing, audit.events.thingy.thing
ignores - audit.users
audit.events.*
matches - audit.events, audit.events.thing
ignores - audit.users, audit.events.thingy.thing
Direct
Routes messages to destinations that exactly match the routing key.
Default
A direct exchange that always exists, where a binding exists for all queues, where the routing key is the queue name.
What are Bindings
A binding links a exchange to a destination.
They have the following:
- Source name: the source exchange
- Destination name: the name of the queue, stream or exchange
- Destination type:
queuefor queues and streams,exchangefor exchanges
Alternate Exchanges
Used to receive messages from exchanges where the message was unrouteable.
Alternate Exchanges are typically fanout with a single unrouted queue.
How to define
It is recommended to define them using policies.