Franz.Common.Mediator.Polly
2.2.16
dotnet add package Franz.Common.Mediator.Polly --version 2.2.16
NuGet\Install-Package Franz.Common.Mediator.Polly -Version 2.2.16
<PackageReference Include="Franz.Common.Mediator.Polly" Version="2.2.16" />
<PackageVersion Include="Franz.Common.Mediator.Polly" Version="2.2.16" />Directory.Packages.props
<PackageReference Include="Franz.Common.Mediator.Polly" />Project file
paket add Franz.Common.Mediator.Polly --version 2.2.16
#r "nuget: Franz.Common.Mediator.Polly, 2.2.16"
#:package Franz.Common.Mediator.Polly@2.2.16
#addin nuget:?package=Franz.Common.Mediator.Polly&version=2.2.16Install as a Cake Addin
#tool nuget:?package=Franz.Common.Mediator.Polly&version=2.2.16Install as a Cake Tool
Franz.Common.Mediator.Polly
Franz.Common.Mediator.Polly extends Franz.Common.Mediator with Polly-based resilience pipelines. It gives you retry, circuit breaker, advanced circuit breaker, timeout, and bulkhead isolation for Mediator requests β all with enriched Serilog logging, context-awareness, and resilience telemetry built-in.
β‘ No extra wiring. No boilerplate. Just plug it in.
- Current Version: v2.2.16
- Target Frameworks: .NET 9+
- Dependencies:
Polly,Serilog,Franz.Common.Mediator
- Part of the private Franz Framework ecosystem.
β¨ Features
π Retry Pipeline β automatic retries with backoff & correlated telemetry.
π¦ Circuit Breaker Pipeline β prevents cascading failures under load.
π Advanced Circuit Breaker Pipeline β trips based on failure ratio in rolling window.
β± Timeout Pipeline β cancels long-running requests automatically.
π¦ Bulkhead Pipeline β limits concurrent requests and queue pressure.
π§ ResilienceContext β shared state across all resilience pipelines:
RetryCount,CircuitOpen,TimeoutOccurred,BulkheadRejected,Duration
π IResilienceObserver β extensibility hooks for external telemetry, alerts, or dashboards.
π Enriched Serilog Logging β all logs include:
- Correlation ID
- Request type
- Policy name
- Pipeline name
- Execution time
- Health indicators
π¦ Installation
dotnet add package Franz.Common.Mediator.Polly
βοΈ Setup
1. Config-driven Entry Point (v1.6.2+)
From v1.6.2, resilience is now config-driven.
Define your policies in appsettings.json:
"Resilience": {
"RetryPolicy": {
"Enabled": true,
"RetryCount": 3,
"RetryIntervalMilliseconds": 500
},
"CircuitBreaker": {
"Enabled": true,
"FailureThreshold": 0.5,
"MinimumThroughput": 10,
"DurationOfBreakSeconds": 30
},
"TimeoutPolicy": {
"Enabled": true,
"TimeoutSeconds": 5
},
"BulkheadPolicy": {
"Enabled": true,
"MaxParallelization": 10,
"MaxQueueSize": 20
}
}
Then just call:
builder.Services.AddFranzResilience(builder.Configuration);
β
Thatβs it β retry, circuit breaker, timeout, and bulkhead are auto-registered from config and wired into Mediator pipelines.
β
Each policy injects structured logs and updates the ResilienceContext.
2. Manual Registration (pre-1.6.2 style)
If you prefer explicit registration:
using Franz.Common.Mediator.Polly;
builder.Services.AddFranzPollyPolicies(options =>
{
options.AddRetry("DefaultRetry", retryCount: 3, intervalMs: 500);
options.AddCircuitBreaker("DefaultCircuitBreaker", 0.5, 10, 30);
options.AddTimeout("DefaultTimeout", 5);
options.AddBulkhead("DefaultBulkhead", 10, 20);
});
builder.Services
.AddFranzPollyRetry("DefaultRetry")
.AddFranzPollyCircuitBreaker("DefaultCircuitBreaker")
.AddFranzPollyTimeout("DefaultTimeout")
.AddFranzPollyBulkhead("DefaultBulkhead");
π§ Observability Enhancements (v1.6.14)
Version 1.6.14 introduces a resilience-awareness layer across all Mediator pipelines.
π§© ResilienceContext
Carries runtime state between pipelines:
public sealed class ResilienceContext
{
public string PolicyName { get; init; } = string.Empty;
public int RetryCount { get; set; }
public bool CircuitOpen { get; set; }
public bool TimeoutOccurred { get; set; }
public bool BulkheadRejected { get; set; }
public TimeSpan Duration { get; set; }
public DateTimeOffset Timestamp { get; } = DateTimeOffset.UtcNow;
public bool IsHealthy => !CircuitOpen && !TimeoutOccurred && !BulkheadRejected;
}
Each pipeline updates this context and emits structured logs through Serilog.
π IResilienceObserver
Observers can listen to policy outcomes globally:
public interface IResilienceObserver
{
void OnPolicyExecuted(string policyName, ResilienceContext context);
}
You can implement custom observers for metrics or telemetry (e.g., Application Insights, Prometheus, Elastic APM).
Example:
public sealed class ElasticResilienceObserver : IResilienceObserver
{
private readonly ILogger<ElasticResilienceObserver> _logger;
public ElasticResilienceObserver(ILogger<ElasticResilienceObserver> logger)
=> _logger = logger;
public void OnPolicyExecuted(string policyName, ResilienceContext context)
=> _logger.LogInformation("π§ {Policy} -> Healthy={Healthy} Duration={Duration}ms Retries={RetryCount}",
policyName, context.IsHealthy, context.Duration.TotalMilliseconds, context.RetryCount);
}
Register it once:
builder.Services.AddSingleton<IResilienceObserver, ElasticResilienceObserver>();
π Pipelines Overview
| Pipeline | Options Class | Key | Observes Context |
|---|---|---|---|
| Retry | PollyRetryPipelineOptions |
"RetryPolicy" |
β |
| Circuit Breaker | PollyCircuitBreakerPipelineOptions |
"CircuitBreaker" |
β |
| Advanced Circuit Breaker | PollyAdvancedCircuitBreakerOptions |
"AdvancedCircuitBreaker" |
β |
| Timeout | PollyTimeoutPipelineOptions |
"TimeoutPolicy" |
β |
| Bulkhead | PollyBulkheadPipelineOptions |
"BulkheadPolicy" |
β |
All pipelines automatically participate in Franzβs logging & correlation system.
π§© Example Logs (v1.6.14)
Success
[12:01:22 INF] βΆοΈ Executing GetBookQuery [abc123] with RetryPolicy
[12:01:22 INF] β
GetBookQuery [abc123] succeeded after 47ms (policy RetryPolicy, retries=0)
Retry + Timeout
[12:01:25 WRN] π GetBookQuery [abc123] retry attempt 2 (policy RetryPolicy)
[12:01:25 ERR] β±οΈ GetBookQuery [abc123] timed out after 5s (policy TimeoutPolicy)
Circuit Breaker Open
[12:01:27 ERR] β GetBookQuery [abc123] failed after 3 retries (policy RetryPolicy)
[12:01:27 WRN] π¦ Circuit opened for 30s (policy CircuitBreaker)
π Benefits
- π§© Composability-first β pipelines remain orthogonal yet share context.
- π§ Self-aware architecture β logs know what policies were triggered.
- π Observer hooks β tap into resilience events for monitoring or dashboards.
- β‘ Zero boilerplate β configured in <20 lines.
- π’ Enterprise-ready β deterministic, auditable, and DI-safe.
πΊ Roadmap
-
FranzResilienceSummaryPipelineβ emits aggregated resilience telemetry per request. - OpenTelemetry integration via Activity tags.
- Prebuilt "DefaultSets" (HTTP, Database, Messaging).
π Changelog
v1.6.14
- π§ Introduced
ResilienceContextβ unified runtime state for all pipelines. - π Added
IResilienceObserverfor external resilience monitoring. - π§Ύ Upgraded all pipelines to emit context-rich Serilog logs.
- π Added correlation ID propagation across all resilience policies.
- π Internal optimizations to reduce policy lookup overhead.
v1.6.2
- β¨ Added
AddFranzResilience(IConfiguration)for config-driven resilience. - β»οΈ Unified policy registry and Mediator pipelines.
- π‘ Simplified startup β <20 lines bootstraps resilience + mediator.
v2.0.1 β Internal Modernization
- Messaging and infrastructure refactored for async, thread-safety, and modern .NET 10 patterns.
- All APIs remain fully backward compatible.
- Tests, listeners, and pipeline components modernized.
β‘ With Franz.Common.Mediator.Polly, resilience is first-class, observable, and deterministic.
Configure it once β and your Mediator pipelines automatically enforce retries, timeouts, bulkheads, and breakers with total visibility.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Franz.Common.Mediator (>= 2.2.16)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.9)
- Polly (>= 8.7.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Franz.Common.Mediator.Polly:
| Package | Downloads |
|---|---|
|
Franz.Common.Messaging.AzureEventBus
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.2.16 | 35 | 7/2/2026 |
| 2.2.15 | 112 | 6/29/2026 |
| 2.2.14 | 106 | 6/29/2026 |
| 2.2.13 | 104 | 6/29/2026 |
| 2.2.12 | 109 | 6/28/2026 |
| 2.2.11 | 122 | 6/28/2026 |
| 2.2.10 | 113 | 6/28/2026 |
| 2.2.9 | 121 | 6/28/2026 |
| 2.2.8 | 111 | 6/28/2026 |
| 2.2.7 | 122 | 6/7/2026 |
| 2.2.6 | 123 | 6/6/2026 |
| 2.2.5 | 127 | 6/4/2026 |
| 2.2.4 | 124 | 6/3/2026 |
| 2.2.3 | 119 | 6/2/2026 |
| 2.2.2 | 128 | 6/2/2026 |
| 2.2.1 | 119 | 5/24/2026 |
| 2.1.4 | 114 | 4/27/2026 |
| 2.1.3 | 115 | 4/26/2026 |
| 2.1.2 | 118 | 4/26/2026 |
| 2.1.1 | 123 | 4/22/2026 |