Interface ITransportLifecycleManager
Manages the lifecycle of transport adapters, providing runtime control over individual transports.
public interface ITransportLifecycleManager
- Extension Methods
Remarks
Implementations are typically registered as an IHostedService to automatically start
all registered transports during application startup and gracefully stop them during shutdown.
Beyond automatic lifecycle management, this interface provides runtime control for scenarios such as:
- Graceful degradation - stop a failing transport while keeping others running
- Dynamic scaling - start/stop transports based on load patterns
- Maintenance windows - temporarily disable specific transports
- Testing scenarios - control transport state during integration tests
Properties
RegisteredTransports
Gets all registered transport adapters.
IReadOnlyCollection<ITransportAdapter> RegisteredTransports { get; }
Property Value
- IReadOnlyCollection<ITransportAdapter>
A read-only collection of transport adapters that have been registered with the lifecycle manager.
Remarks
This collection includes both running and stopped transports. Use IsRunning to check individual transport status.
TransportNames
Gets all transport names that are currently registered.
IReadOnlyCollection<string> TransportNames { get; }
Property Value
- IReadOnlyCollection<string>
A read-only collection of transport names.
Methods
IsRegistered(string)
Checks if a transport with the specified name is registered.
bool IsRegistered(string name)
Parameters
namestringThe name of the transport to check.
Returns
Exceptions
- ArgumentException
Thrown when
nameis null or empty.
StartTransportAsync(string, CancellationToken)
Starts a specific transport adapter by name.
Task StartTransportAsync(string name, CancellationToken cancellationToken)
Parameters
namestringThe name of the transport to start.
cancellationTokenCancellationTokenCancellation token for the operation.
Returns
- Task
A task representing the asynchronous start operation.
Remarks
If the transport is already running, this method returns immediately without error.
Exceptions
- ArgumentException
Thrown when
nameis null or empty.- InvalidOperationException
Thrown when no transport with the specified name is registered.
StopTransportAsync(string, CancellationToken)
Stops a specific transport adapter by name.
Task StopTransportAsync(string name, CancellationToken cancellationToken)
Parameters
namestringThe name of the transport to stop.
cancellationTokenCancellationTokenCancellation token for the operation.
Returns
- Task
A task representing the asynchronous stop operation.
Remarks
If the transport is already stopped, this method returns immediately without error.
The stop operation includes a drain period to allow in-flight messages to complete processing before forcing shutdown.
Exceptions
- ArgumentException
Thrown when
nameis null or empty.- InvalidOperationException
Thrown when no transport with the specified name is registered.