PollyHangfire 1.0.0
dotnet add package PollyHangfire --version 1.0.0
NuGet\Install-Package PollyHangfire -Version 1.0.0
<PackageReference Include="PollyHangfire" Version="1.0.0" />
<PackageVersion Include="PollyHangfire" Version="1.0.0" />
<PackageReference Include="PollyHangfire" />
paket add PollyHangfire --version 1.0.0
#r "nuget: PollyHangfire, 1.0.0"
#:package PollyHangfire@1.0.0
#addin nuget:?package=PollyHangfire&version=1.0.0
#tool nuget:?package=PollyHangfire&version=1.0.0
PollyHangfire
Polly v8 resilience pipelines for Hangfire — retry, timeout, and circuit-breaker for IBackgroundJobClient.Enqueue and Schedule.
The gap Hangfire leaves open
Hangfire's built-in retry applies to job execution on the server side. It does not protect the client side — when your app calls Enqueue() or Schedule() and the backing job store (Redis, SQL Server, etc.) is temporarily unavailable, you get an unhandled BackgroundJobClientException or DistributedLockTimeoutException.
PollyHangfire fills that gap.
Installation
dotnet add package PollyHangfire
Quick start
DI registration
`csharp services.AddPollyHangfire(pipeline ⇒ pipeline .AddRetry(new RetryStrategyOptions { MaxRetryAttempts = 3, Delay = TimeSpan.FromMilliseconds(500), BackoffType = DelayBackoffType.Exponential, ShouldHandle = HangfireTransientErrors.IsTransient, }) .AddTimeout(TimeSpan.FromSeconds(10)));
// Requires IBackgroundJobClient to already be registered (e.g. via services.AddHangfire(...)) public class OrderService(ResilientBackgroundJobClient jobs) { public void PlaceOrder(Order order) ⇒ jobs.Enqueue<IOrderProcessor>(p ⇒ p.ProcessAsync(order)); } `
WithPolly() extension on existing client
`csharp IBackgroundJobClient client = new BackgroundJobClient();
var resilient = client.WithPolly(pipeline ⇒ pipeline.AddRetry(new RetryStrategyOptions { MaxRetryAttempts = 3, Delay = TimeSpan.FromMilliseconds(500), BackoffType = DelayBackoffType.Exponential, ShouldHandle = HangfireTransientErrors.IsTransient, }));
resilient.Enqueue<IEmailSender>(s ⇒ s.SendWelcomeEmailAsync(userId)); resilient.Schedule<IReportGenerator>(r ⇒ r.GenerateAsync(reportId), TimeSpan.FromHours(1)); `
API surface
| Method | Description |
|---|---|
| Enqueue(Expression<Action>) | Enqueue fire-and-forget job |
| Enqueue<T>(Expression<Action<T>>) | Enqueue typed fire-and-forget job |
| Schedule(Expression<Action>, TimeSpan) | Schedule delayed job |
| Schedule<T>(Expression<Action<T>>, TimeSpan) | Schedule typed delayed job |
| Execute<T>(Func<T>) | Execute arbitrary function in pipeline |
Transient error predicate
HangfireTransientErrors.IsTransient handles:
| Exception | Reason |
|---|---|
| BackgroundJobClientException | Job store temporarily unavailable |
| DistributedLockTimeoutException | Distributed lock acquisition failed |
| TimeoutException | Store connection or command timed out |
| TaskCanceledException | Operation cancelled |
Supported frameworks
et6.0 · et8.0 · et9.0
Related packages
| Package | Wraps |
|---|---|
| PollyEFCore | Entity Framework Core DbContext |
| PollyDapper | Dapper IDbConnection |
| PollyMongo | MongoDB IMongoCollection<T> |
| PollyAzureBlob | Azure Blob Storage BlobContainerClient |
| PollyNpgsql | Npgsql PostgreSQL NpgsqlConnection |
| PollySqlClient | System.Data.SqlClient SqlConnection |
| PollyCosmosDb | Azure Cosmos DB CosmosClient |
| PollyGrpc | gRPC channel calls |
| PollyRabbitMQ | RabbitMQ IModel channel |
| PollyAzureServiceBus | Azure Service Bus sender/receiver |
| PollyRedis | StackExchange.Redis IDatabase |
| PollyMediatR | MediatR IMediator |
| PollyOpenAI | OpenAI ChatClient |
| PollyHealthChecks | ASP.NET Core health checks |
| PollyBackoff | Pre-built backoff pipelines |
| PollyChaos | Chaos engineering helpers |
| PollyKafka | Confluent Kafka producer/consumer |
| PollySignalR | SignalR HubConnection |
| PollyRateLimiter | .NET rate limiting middleware |
| PollyElasticsearch | Elastic.Clients.Elasticsearch |
| PollyAzureKeyVault | Azure Key Vault SecretClient |
| PollyAzureEventHub | Azure Event Hubs producer |
| PollySendGrid | SendGrid email client |
| PollyMassTransit | MassTransit IBus |
| PollyAzureTableStorage | Azure Table Storage TableClient |
| PollyMailKit | MailKit SMTP email client |
| PollyAzureQueueStorage | Azure Queue Storage QueueClient |
License
MIT © Justin Bannister
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 is compatible. 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 was computed. 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. |
-
net6.0
- Hangfire.Core (>= 1.8.23)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Polly.Core (>= 8.7.0)
-
net8.0
- Hangfire.Core (>= 1.8.23)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Polly.Core (>= 8.7.0)
-
net9.0
- Hangfire.Core (>= 1.8.23)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Polly.Core (>= 8.7.0)
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 |
|---|---|---|
| 1.0.0 | 49 | 6/24/2026 |
1.0.0: Initial release. ResilientBackgroundJobClient wraps IBackgroundJobClient in a Polly v8 ResiliencePipeline. Covers Enqueue and Schedule operations with client-side resilience. HangfireTransientErrors.IsTransient covers JobStorageException, TimeoutException, and TaskCanceledException. Supports net6.0, net8.0, net9.0.