Exchange Chains¶
Exchange chains allow a message to move from one exchange to another.
This is useful when routing must be composed in multiple steps.
Topology¶
graph LR
Publisher --> Orders["orders"]
Orders --> Integration["orders.integration"]
Integration --> Audit["orders.audit"]
Integration --> Analytics["orders.analytics"]
Descriptor¶
var descriptor = new PublisherBoundDescriptor
{
Exchanges =
{
new ExchangeBoundDescriptor
{
Name = "orders",
Type = ExchangeTypes.Direct,
Durable = true,
Exchanges =
{
new ExchangeBoundDescriptor
{
Name = "orders.integration",
Type = ExchangeTypes.Direct,
Durable = true,
Exchanges =
{
new ExchangeBoundDescriptor
{
Name = "orders.audit",
Type = ExchangeTypes.Direct,
Durable = true
},
new ExchangeBoundDescriptor
{
Name = "orders.analytics",
Type = ExchangeTypes.Direct,
Durable = true
}
}
}
}
}
}
};
Exchange Chain With Queue¶
graph LR
Publisher --> Orders["orders"]
Orders --> Integration["orders.integration"]
Integration --> Queue["orders.integration.queue"]
var descriptor = new PublisherBoundDescriptor
{
Exchanges =
{
new ExchangeBoundDescriptor
{
Name = "orders",
Type = ExchangeTypes.Direct,
Durable = true,
Exchanges =
{
new ExchangeBoundDescriptor
{
Name = "orders.integration",
Type = ExchangeTypes.Direct,
Durable = true,
Queues =
{
new QueueBoundDescriptor
{
Name = "orders.integration.queue",
Durable = true,
AutoDelete = false
}
}
}
}
}
}
};
When To Use¶
Use exchange chains when:
- routing should be layered;
- integration routing must be separated from internal routing;
- messages must be replicated to downstream exchanges;
- topology should be configured without changing publisher code.