Class TransportAdapterRouter
Default implementation of transport adapter router that routes messages through the dispatcher pipeline.
public sealed class TransportAdapterRouter : ITransportAdapterRouter
- Inheritance
-
TransportAdapterRouter
- Implements
- Inherited Members
- Extension Methods
Remarks
Initializes a new instance of the TransportAdapterRouter class.
Constructors
TransportAdapterRouter(IDispatcher, ILogger<TransportAdapterRouter>)
Default implementation of transport adapter router that routes messages through the dispatcher pipeline.
public TransportAdapterRouter(IDispatcher dispatcher, ILogger<TransportAdapterRouter> logger)
Parameters
dispatcherIDispatcherThe dispatcher to route messages through.
loggerILogger<TransportAdapterRouter>The logger.
Remarks
Initializes a new instance of the TransportAdapterRouter class.
Methods
CheckAdapterHealthAsync(CancellationToken)
Gets the health status of all registered transport adapters.
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public Task<IDictionary<string, HealthCheckResult>> CheckAdapterHealthAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenToken to cancel the health check operation.
Returns
- Task<IDictionary<string, HealthCheckResult>>
A task containing the health check results for all adapters.
RegisterAdapterAsync(IMessageBusAdapter, string, CancellationToken)
Registers a transport adapter with the router for message routing.
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public Task RegisterAdapterAsync(IMessageBusAdapter adapter, string adapterId, CancellationToken cancellationToken)
Parameters
adapterIMessageBusAdapterThe transport adapter to register.
adapterIdstringThe unique identifier for the adapter.
cancellationTokenCancellationTokenToken to cancel the registration operation.
Returns
- Task
A task representing the registration operation.
RouteAsync(IDispatchMessage, IMessageContext, string, CancellationToken)
Routes a message received from a transport adapter through the dispatcher pipeline.
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public Task<IMessageResult> RouteAsync(IDispatchMessage message, IMessageContext context, string adapterId, CancellationToken cancellationToken)
Parameters
messageIDispatchMessageThe message received from the transport.
contextIMessageContextThe message context containing transport metadata.
adapterIdstringThe identifier of the transport adapter that received the message.
cancellationTokenCancellationTokenToken to cancel the routing operation.
Returns
- Task<IMessageResult>
A task representing the routing operation result.
RouteBatchAsync(IReadOnlyList<IDispatchMessage>, IReadOnlyList<IMessageContext>, string, CancellationToken)
Routes a message batch received from a transport adapter through the dispatcher pipeline.
public Task<IReadOnlyList<IMessageResult>> RouteBatchAsync(IReadOnlyList<IDispatchMessage> messages, IReadOnlyList<IMessageContext> contexts, string adapterId, CancellationToken cancellationToken)
Parameters
messagesIReadOnlyList<IDispatchMessage>The batch of messages received from the transport.
contextsIReadOnlyList<IMessageContext>The message contexts for each message in the batch.
adapterIdstringThe identifier of the transport adapter that received the messages.
cancellationTokenCancellationTokenToken to cancel the routing operation.
Returns
- Task<IReadOnlyList<IMessageResult>>
A task representing the batch routing operation results.
UnregisterAdapterAsync(string, CancellationToken)
Unregisters a transport adapter from the router.
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public Task UnregisterAdapterAsync(string adapterId, CancellationToken cancellationToken)
Parameters
adapterIdstringThe identifier of the adapter to unregister.
cancellationTokenCancellationTokenToken to cancel the unregistration operation.
Returns
- Task
A task representing the unregistration operation.