Skip to content

Commit 7674219

Browse files
authored
Merge pull request #7737 from Particular/review-routing-topology
Review routing topology
2 parents 4395a93 + f3184be commit 7674219

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

transports/rabbitmq/routing-topology.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Routing topology
3-
summary: Information about the routing topology options available in RabbitMQ and how they impact NServiceBus systems
4-
reviewed: 2023-11-07
3+
summary: Learn about the routing topology options in RabbitMQ and how they impact NServiceBus systems
4+
reviewed: 2025-08-14
55
component: Rabbit
66
versions: '[2,]'
77
related:
@@ -10,50 +10,50 @@ redirects:
1010
- nservicebus/rabbitmq/routing-topology
1111
---
1212

13+
The RabbitMQ transport uses a *routing topology* to control how exchanges, queues, and bindings are created in the broker. The routing topology also defines how these exchanges are used for sending and publishing messages.
1314

14-
The RabbitMQ transport has the concept of a routing topology, which controls how it creates exchanges, queues, and the bindings between them in the RabbitMQ broker. The routing topology also controls how the transport uses the exchanges it creates to send and publish messages. All endpoints in a system must use the same routing topology to be able to communicate with each other. For new systems, the [conventional routing topology](routing-topology.md#conventional-routing-topology) should be used. The [direct routing topology](routing-topology.md#direct-routing-topology) is recommended only when adding an endpoint to an existing system that already uses that routing topology. A custom routing topology can be useful when integrating with a legacy system.
15+
All endpoints in a system must use the same routing topology to communicate. For new systems, use the [conventional routing topology](routing-topology.md#conventional-routing-topology). The [direct routing topology](routing-topology.md#direct-routing-topology) should only be used when adding endpoints to an existing system that already relies on it. A custom routing topology may be useful when integrating with legacy systems.
1516

17+
---
1618

1719
## Conventional routing topology
1820

19-
The conventional routing topology relies on [fanout exchanges](https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchange-fanout) to route messages.
20-
21-
> [!NOTE]
22-
> The recommended routing topology is the conventional routing topology. It was the default topology prior to NServiceBus.RabbitMQ version 5.
23-
24-
25-
### Sending using the conventional routing topology
21+
The conventional routing topology uses [fanout exchanges](https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchange-fanout) to route messages.
2622

27-
Each endpoint creates a pair of a *fanout* exchange and a queue named after the endpoint's name. It also creates a binding between them. Messages are sent to the endpoint by publishing them to the endpoint's exchange. The binding then routes the message to the endpoint's queue.
23+
> [!NOTE]
24+
> This is the recommended routing topology. It was the default prior to NServiceBus.RabbitMQ version 5.
2825
26+
### Sending
2927

30-
### Publishing using the conventional routing topology
28+
Each endpoint creates a *fanout* exchange and a queue with the same name as the endpoint. A binding connects them.
29+
Messages are sent by publishing them to the endpoint’s exchange, which then routes them to the queue.
3130

32-
For each type being published, a series of *fanout* exchanges are created to model the inheritance hierarchy of the type. For each type involved, an exchange is created, named in the following format: `Namespace:TypeName`. Bindings are created between the types, going from child to parent, until the entire hierarchy has been modeled. Exchanges are also created for each interface the type implements.
31+
### Publishing
3332

34-
When an endpoint subscribes to an event, it first ensures that the above infrastructure exists. It then adds a binding from the exchange corresponding to the subscribed type to its own exchange.
33+
For each event type, a set of *fanout* exchanges is created to represent its inheritance hierarchy.
34+
- Each type has an exchange named `Namespace:TypeName`.
35+
- Bindings connect child types to their parents, modeling the full hierarchy.
36+
- Exchanges are also created for each implemented interface.
3537

36-
When an endpoint publishes an event, it first ensures that the above infrastructure exists. It then publishes the message to the exchange corresponding to the message type being published.
38+
When subscribing, an endpoint ensures the infrastructure exists and then adds a binding from the subscribed type’s exchange to its own exchange.
3739

40+
When publishing, the endpoint ensures the infrastructure exists and then publishes to the exchange of the event type.
3841

39-
### Enabling the conventional routing topology
40-
41-
To enable the conventional routing topology, use the following configuration:
42+
### Enabling
4243

4344
snippet: rabbitmq-config-useconventionalroutingtopology
4445

45-
4646
## Direct routing topology
4747

48-
The direct routing topology routes all events through a single exchange, `amq.topic` by default. Events are published using a *routing key* based on the event type, and subscribers will use that key to filter their subscriptions.
48+
The direct routing topology routes all events through a single exchange (default: `amq.topic`). Events are published with a routing key based on the event type, and subscribers use that key to filter messages.
4949

50+
### Sending
5051

51-
### Sending using the direct routing topology
52+
Each endpoint creates a queue named after the endpoint.
5253

53-
Every endpoint creates a queue named after the endpoint's name. When an endpoint sends a message it publishes it to a default exchange with a *routing key* equal to the destination endpoint name. This makes use of RabbitMQ [default exchanges](https://www.rabbitmq.com/tutorials/amqp-concepts.html) to move the message to a queue with the same name.
54+
When sending, the message is published to the [default exchange](https://www.rabbitmq.com/tutorials/amqp-concepts.html) with a routing key equal to the destination endpoint name. This leverages RabbitMQ default exchanges to deliver messages directly to the queue.
5455

55-
56-
### Publishing using the direct routing topology
56+
### Publishing
5757

5858
Every endpoint publishes an event using the `amq.topic` exchange with a *routing key* of the form `Namespace.TypeName`, corresponding to the type of the event. The event is moved to all queues that have a binding for that event type.
5959

@@ -62,14 +62,13 @@ An endpoint that subscribes to a given event creates a binding to the default ex
6262
> [!WARNING]
6363
> In accordance with the [AMQP 0.9.1 standard](https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.publish.routing-key) the *routing key* has a length limit of 255 characters.
6464
65-
66-
### Enabling the direct routing topology
65+
### Enabling
6766

6867
To enable the direct routing topology, use the following configuration:
6968

7069
snippet: rabbitmq-config-usedirectroutingtopology
7170

72-
### Overriding the default conventions
71+
### Overriding conventions
7372

7473
The default conventions for exchange names and routing keys can be overridden by using the following overload:
7574

transports/upgrades/rabbitmq-4to5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ See [routing topology](/transports/rabbitmq/routing-topology.md) for further det
2020

2121
## Direct routing topology changes
2222

23-
The convention for overriding the name of the exchange used when publishing events has changed. The address and the event type are no longer passed to the `exchangeNameConvention` parameter of the [UseDirectRoutingTopology](/transports/rabbitmq/routing-topology.md#direct-routing-topology-enabling-the-direct-routing-topology) method.
23+
The convention for overriding the name of the exchange used when publishing events has changed. The address and the event type are no longer passed to the `exchangeNameConvention` parameter of the [UseDirectRoutingTopology](/transports/rabbitmq/routing-topology.md#direct-routing-topology-enabling) method.
2424

2525
```csharp
2626
// For RabbitMQ Transport version 5.x

0 commit comments

Comments
 (0)