Class RoutingBuilderExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Excalibur.Dispatch.dll
Extension methods for configuring unified routing in the Excalibur framework.
public static class RoutingBuilderExtensions
- Inheritance
-
RoutingBuilderExtensions
- Inherited Members
Methods
UseRouting(IDispatchBuilder, Action<IRoutingBuilder>)
Configures unified message routing using the fluent routing builder.
public static IDispatchBuilder UseRouting(this IDispatchBuilder builder, Action<IRoutingBuilder> configure)
Parameters
builderIDispatchBuilderThe dispatch builder to configure.
configureAction<IRoutingBuilder>Action to configure routing rules.
Returns
- IDispatchBuilder
The builder for chaining.
Examples
services.AddDispatch(dispatch =>
{
dispatch.UseRouting(routing =>
{
// Transport routing - which message bus?
routing.Transport
.Route<OrderCreated>().To("rabbitmq")
.Route<PaymentProcessed>().To("kafka")
.Default("local");
// Endpoint routing - which services?
routing.Endpoints
.Route<OrderCreated>()
.To("billing-service", "inventory-service")
.When(msg => msg.Amount > 1000).AlsoTo("fraud-detection");
// Optional: Configure fallback for unmatched messages
routing.Fallback.To("dead-letter-queue");
});
});
Remarks
This method provides a unified entry point for configuring both transport selection and endpoint routing. It registers the necessary services and applies the routing configuration.
The fluent API supports two-tier routing:
- Transport tier: Determines which message bus handles the message
- Endpoint tier: Determines which services receive the message
Exceptions
- ArgumentNullException
Thrown when
builderorconfigureis null.