Table of Contents

Class RoutingMiddleware

Namespace
Excalibur.Dispatch.Routing
Assembly
Excalibur.Dispatch.dll

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

router IDispatchRouter

The unified dispatch router.

logger ILogger<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

message IDispatchMessage

The message being routed.

context IMessageContext

The message context to update with routing results.

nextDelegate DispatchRequestDelegate

The next middleware in the pipeline.

cancellationToken CancellationToken

Token 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.