Table of Contents

Interface ITransportSelector

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

Service responsible for selecting the appropriate transport (message bus) for a message.

public interface ITransportSelector
Extension Methods

Examples

services.AddDispatch(dispatch =>
{
    dispatch.UseRouting(routing =>
    {
        routing.Transport
            .Route<OrderCreated>().To("rabbitmq")
            .Route<PaymentProcessed>().To("kafka")
            .Default("local");
    });
});

Remarks

The transport selector determines which message bus should handle a given message. Common transports include "local" (in-process), "rabbitmq", "kafka", "azureservicebus", etc.

This interface replaces the former IRouterService with clearer naming that distinguishes transport selection from endpoint routing.

Methods

GetAvailableTransports(Type)

Gets all available transports that can handle the specified message type.

IEnumerable<string> GetAvailableTransports(Type messageType)

Parameters

messageType Type

The type of message to check.

Returns

IEnumerable<string>

A collection of transport names that have rules configured for the message type, plus the default transport.

Exceptions

ArgumentNullException

Thrown when messageType is null.

SelectTransportAsync(IDispatchMessage, IMessageContext, CancellationToken)

Selects the transport for a message based on configured routing rules.

ValueTask<string> SelectTransportAsync(IDispatchMessage message, IMessageContext context, CancellationToken cancellationToken)

Parameters

message IDispatchMessage

The message to route.

context IMessageContext

The message context containing metadata and state.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

ValueTask<string>

The name of the selected transport (e.g., "local", "rabbitmq", "kafka").

Exceptions

ArgumentNullException

Thrown when message or context is null.