Class RoutingMiddleware
Middleware responsible for determining the message bus route for dispatched messages.
public sealed class RoutingMiddleware : IDispatchMiddleware
- Inheritance
-
RoutingMiddleware
- Implements
- Inherited Members
- Extension Methods
Remarks
This middleware uses IDispatchRouter which combines transport selection and
endpoint routing into a single RoutingDecision. Configure routing using the
fluent builder API via UseRouting().
Constructors
RoutingMiddleware(IDispatchRouter, ILogger<RoutingMiddleware>)
Initializes a new instance of the RoutingMiddleware class.
public RoutingMiddleware(IDispatchRouter router, ILogger<RoutingMiddleware> logger)
Parameters
routerIDispatchRouterThe unified dispatch router.
loggerILogger<RoutingMiddleware>Logger for diagnostic information.
Exceptions
- ArgumentNullException
Thrown when router or logger is null.
Properties
Stage
Gets the pipeline stage where this middleware executes.
public DispatchMiddlewareStage? Stage { get; }
Property Value
- DispatchMiddlewareStage?
Returns Routing.
Methods
InvokeAsync(IDispatchMessage, IMessageContext, DispatchRequestDelegate, CancellationToken)
Determines the route for the message and updates the context with routing information.
public ValueTask<IMessageResult> InvokeAsync(IDispatchMessage message, IMessageContext context, DispatchRequestDelegate nextDelegate, CancellationToken cancellationToken)
Parameters
messageIDispatchMessageThe message being routed.
contextIMessageContextThe message context to update with routing results.
nextDelegateDispatchRequestDelegateThe next middleware in the pipeline.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- ValueTask<IMessageResult>
The result from the next middleware if routing succeeds, or a failure result with 404 status if routing fails.
Exceptions
- ArgumentNullException
Thrown when required parameters are null.