Bsft.Resilience.Mediator 2.2.0

dotnet add package Bsft.Resilience.Mediator --version 2.2.0
                    
NuGet\Install-Package Bsft.Resilience.Mediator -Version 2.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bsft.Resilience.Mediator" Version="2.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bsft.Resilience.Mediator" Version="2.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Bsft.Resilience.Mediator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bsft.Resilience.Mediator --version 2.2.0
                    
#r "nuget: Bsft.Resilience.Mediator, 2.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bsft.Resilience.Mediator@2.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bsft.Resilience.Mediator&version=2.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Bsft.Resilience.Mediator&version=2.2.0
                    
Install as a Cake Tool

Bsft.Resilience.Mediator

The behavior package of the Bsft.Resilience family: a mediator pipeline behavior that retries requests marked with [Retryable] on transient failures, over a Polly pipeline built once per process.

Install

dotnet add package Bsft.Resilience.Mediator

Requires Bsft.Mediator.Abstractions, Bsft.Core and Polly.Core (all pulled transitively). It does not reference Bsft.Resilience: the HTTP half and the mediator half share a name and nothing else, so a host retrying commands takes neither the HTTP resilience stack nor the correlation handler along.

Register

services.AddBsftResilienceMediator(options =>
{
    options.MaxRetryAttempts = 3;
});

// or bound from configuration, section "Bsft:Resilience:Mediator"
services.AddBsftResilienceMediator(configuration);

Then mark the requests that may safely run twice:

[Retryable]
public sealed record SyncProductPriceQuery(Guid ProductId) : IQuery<decimal>;

With UseDefaults() the position is the framework's, not the registration order: retry runs outside the transaction behavior, so each attempt gets its own transaction, and inside authorization, validation and audit, which therefore run once per request. Without UseDefaults(), registration order is the pipeline order, so call this after AddBsftMediator. Apply the marker only to idempotent requests — retrying a command with side effects duplicates them.

Configure

Option Default Effect
BsftResilienceMediatorOptions.MaxRetryAttempts 3 Retries performed after the initial invocation.
BsftResilienceMediatorOptions.BaseDelay 200ms Base delay between retries; grows exponentially and is randomized with jitter.
BsftResilienceMediatorOptions.ShouldRetry IsTransientFailure Decides which exception is transient. The default retries everything except cancellation and the deterministic Bsft.Core domain exceptions (validation, business rule, not found, forbidden, conflict).

Validation: a negative retry count, a negative delay and a null predicate are rejected at registration and again on ValidateOnStart, each naming the member and the offending value. ShouldRetry has no configuration binding — it is a delegate — so a section can set the first two members only.

Extend

IMediatorResiliencePipelineProvider — supplies the shared ResiliencePipeline the behavior executes through. The default builds it once from the options and reuses it; replace the registration to run requests through a pipeline this package cannot describe (a bulkhead, a hedging strategy, a circuit breaker over the mediator).

Documentation

Topic page: docs/resilience.md. Conventions: docs/package-conventions.md.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.0 75 10/23/2026
2.1.0 91 9/28/2026