You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: transports/rabbitmq/routing-topology.md
+26-27Lines changed: 26 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
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
5
5
component: Rabbit
6
6
versions: '[2,]'
7
7
related:
@@ -10,50 +10,50 @@ redirects:
10
10
- nservicebus/rabbitmq/routing-topology
11
11
---
12
12
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.
13
14
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.
15
16
17
+
---
16
18
17
19
## Conventional routing topology
18
20
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.
26
22
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.
28
25
26
+
### Sending
29
27
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.
31
30
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
33
32
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.
35
37
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.
37
39
40
+
When publishing, the endpoint ensures the infrastructure exists and then publishes to the exchange of the event type.
38
41
39
-
### Enabling the conventional routing topology
40
-
41
-
To enable the conventional routing topology, use the following configuration:
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.
49
49
50
+
### Sending
50
51
51
-
### Sending using the direct routing topology
52
+
Each endpoint creates a queue named after the endpoint.
52
53
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.
54
55
55
-
56
-
### Publishing using the direct routing topology
56
+
### Publishing
57
57
58
58
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.
59
59
@@ -62,14 +62,13 @@ An endpoint that subscribes to a given event creates a binding to the default ex
62
62
> [!WARNING]
63
63
> 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.
64
64
65
-
66
-
### Enabling the direct routing topology
65
+
### Enabling
67
66
68
67
To enable the direct routing topology, use the following configuration:
69
68
70
69
snippet: rabbitmq-config-usedirectroutingtopology
71
70
72
-
### Overriding the default conventions
71
+
### Overriding conventions
73
72
74
73
The default conventions for exchange names and routing keys can be overridden by using the following overload:
Copy file name to clipboardExpand all lines: transports/upgrades/rabbitmq-4to5.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ See [routing topology](/transports/rabbitmq/routing-topology.md) for further det
20
20
21
21
## Direct routing topology changes
22
22
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.
0 commit comments