PollyHangfire 1.0.0

dotnet add package PollyHangfire --version 1.0.0
                    
NuGet\Install-Package PollyHangfire -Version 1.0.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="PollyHangfire" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PollyHangfire" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PollyHangfire" />
                    
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 PollyHangfire --version 1.0.0
                    
#r "nuget: PollyHangfire, 1.0.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 PollyHangfire@1.0.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=PollyHangfire&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PollyHangfire&version=1.0.0
                    
Install as a Cake Tool

PollyHangfire

NuGet NuGet Downloads CI License: MIT

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

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 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. 
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
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.