Class TransportAdapterHostedServiceOptions
Configuration options for the transport adapter hosted service.
public sealed class TransportAdapterHostedServiceOptions
- Inheritance
-
TransportAdapterHostedServiceOptions
- Inherited Members
- Extension Methods
Fields
DefaultDrainTimeoutSeconds
The default drain timeout in seconds: 80% of the host's default shutdown budget, leaving the remaining 20% as margin.
public const int DefaultDrainTimeoutSeconds = 24
Field Value
Remarks
The host cancels the shutdown token at HostOptions.ShutdownTimeout,
whose default is 30 seconds. A drain budget equal to it is not inside it: the host can abandon the
drain at the same instant the drain is still entitled to run, truncating it. This default is
therefore 24 seconds rather than 30, so the drain always completes or times out on its own terms.
Properties
DrainTimeout
Gets the drain timeout as a TimeSpan.
public TimeSpan DrainTimeout { get; }
Property Value
- TimeSpan
The drain timeout duration.
DrainTimeoutSeconds
Gets or sets the timeout in seconds to wait for pending messages to drain during shutdown.
public int DrainTimeoutSeconds { get; set; }
Property Value
- int
The drain timeout in seconds. Default is 24 seconds.
Remarks
During graceful shutdown, the service will wait up to this duration for transport adapters to complete processing any in-flight messages before forcing a stop.
This budget must stay strictly inside the host's shutdown budget. The host cancels the shutdown
token at HostOptions.ShutdownTimeout (30 seconds by
default), so a drain of 30 seconds would be abandoned mid-drain rather than running to completion.
The default of 24 seconds is 80% of the host default, leaving 20% as margin.
The two settings are related but not linked: changing
HostOptions.ShutdownTimeout does NOT move this value.
If you raise or lower the host shutdown budget, set this to at most 80% of the new value; a drain
budget at or above the host's cannot be honoured, because the host stops waiting first.
ThrowOnStartupFailure
Gets or sets a value indicating whether to throw an exception if a transport adapter fails to start.
public bool ThrowOnStartupFailure { get; set; }
Property Value
- bool
true to throw on startup failure and prevent the application from starting; false to log the error and continue with remaining adapters. Default is true.
Remarks
In production environments, it is recommended to keep this as true to ensure all required transports are operational before accepting traffic.