Class BackgroundExecutionPipelineExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Excalibur.Dispatch.dll
Extension methods for adding background execution middleware to the dispatch pipeline.
public static class BackgroundExecutionPipelineExtensions
- Inheritance
-
BackgroundExecutionPipelineExtensions
- Inherited Members
Methods
UseBackgroundExecution(IDispatchBuilder)
Adds background execution middleware to the dispatch pipeline.
public static IDispatchBuilder UseBackgroundExecution(this IDispatchBuilder builder)
Parameters
builderIDispatchBuilderThe dispatch builder.
Returns
- IDispatchBuilder
The builder for fluent configuration.
Remarks
The background execution middleware offloads handler execution to a background thread, allowing the caller to return immediately while processing continues asynchronously.
This method also registers the hosted service that awaits in-flight background work when the host
stops gracefully, bounded by HostOptions.ShutdownTimeout. Work still running when that budget
elapses is signalled to cancel, and is lost and logged as an error: background execution is
in-process and best-effort, not durable. Work that must survive a crash or restart belongs in the outbox.
What happens when a background message fails is set by
ExceptionBehavior, configured with
services.Configure<BackgroundExecutionOptions>(...).
Recommended pipeline order:
builder.UseAuthentication()
.UseAuthorization()
.UseValidation()
.UseBackgroundExecution() // Offload after validation
.UseRetry();