Interface ITransportContextProvider
Provides transport context for incoming messages, enabling pipeline profile selection based on message origin before the pipeline is constructed.
public interface ITransportContextProvider
- Extension Methods
Examples
// In Dispatcher.DispatchAsync:
var binding = _transportContextProvider.GetTransportBinding(context);
var profile = await _profileResolver.ResolveProfileAsync(message, context, binding, ct);
var pipeline = _pipelineFactory.CreatePipeline(profile);
return await pipeline.ExecuteAsync(message, context, ct);
Remarks
This interface is used by the Dispatcher to resolve the transport binding for an incoming message before selecting the pipeline profile. This ensures that transport-specific pipeline profiles are applied correctly.
The transport binding is resolved by examining context properties set by the transport adapter when the message was received. If no transport binding is found (e.g., for directly dispatched messages), the method returns null.
Important: This resolution must happen in the Dispatcher, before the pipeline profile is resolved, to ensure the correct pipeline profile is selected before the middleware chain is constructed.
Methods
GetTransportBinding(IMessageContext)
Gets the transport binding for an incoming message, if available.
ITransportBinding? GetTransportBinding(IMessageContext context)
Parameters
contextIMessageContextThe message context containing transport metadata.
Returns
- ITransportBinding
The transport binding if the message originated from a transport adapter; otherwise, null for directly dispatched messages.
Remarks
The implementation should look for transport-specific context properties
such as TransportBindingName or TransportEndpoint that were
set by the transport adapter when the message was received.
This method must be thread-safe and should not throw exceptions for missing transport context - it should simply return null.