PollyMassTransit 1.0.2

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

PollyMassTransit

NuGet NuGet Downloads CI License: MIT

Polly v8 producer-side resilience for MassTransit — add retry, timeout, and circuit-breaker to IBus.Publish and SendAsync in two lines.

Key differentiator: MassTransit's built-in retry only applies to consumers. This library fills the producer-side gap.

var resilient = bus.WithPolly(pipeline => pipeline
    .AddRetry(new RetryStrategyOptions
    {
        MaxRetryAttempts = 3,
        Delay = TimeSpan.FromSeconds(1),
        BackoffType = DelayBackoffType.Exponential,
        UseJitter = true,
        ShouldHandle = MassTransitTransientErrors.IsTransient,
    })
    .AddTimeout(TimeSpan.FromSeconds(10)));

await resilient.PublishAsync(new OrderPlaced { OrderId = id }, cancellationToken);

Why PollyMassTransit?

MassTransit's retry middleware sits on the consumer pipeline — it retries message processing. When the producer (your application code publishing or sending messages) fails due to a transient broker outage, MassTransit does nothing. This library adds Polly v8 to the producer side:

Problem Solution
RequestTimeoutException during request-reply Caught by MassTransitTransientErrors.IsTransient
TimeoutException at the transport layer Caught by MassTransitTransientErrors.IsTransient
HttpRequestException (HTTP transport) Caught by MassTransitTransientErrors.IsTransient
TaskCanceledException timeout in transit Caught by MassTransitTransientErrors.IsTransient
Cascading failures during broker downtime Wrap with AddCircuitBreaker

Installation

dotnet add package PollyMassTransit
dotnet add package Polly.Core

Quick-start

1. Manual wiring

// bus is the IBus registered by services.AddMassTransit(...)
var resilient = bus.WithPolly(p => p
    .AddRetry(new RetryStrategyOptions
    {
        MaxRetryAttempts = 3,
        Delay = TimeSpan.FromSeconds(1),
        BackoffType = DelayBackoffType.Exponential,
        UseJitter = true,
        ShouldHandle = MassTransitTransientErrors.IsTransient,
    }));

await resilient.PublishAsync(new OrderPlaced { OrderId = orderId }, ct);
await resilient.SendAsync(new Uri("queue:orders"), new CreateOrder { ... }, ct);

2. Dependency injection

// After services.AddMassTransit(...)
builder.Services.AddPollyMassTransit(pipeline => pipeline
    .AddRetry(new RetryStrategyOptions
    {
        MaxRetryAttempts = 3,
        Delay = TimeSpan.FromSeconds(1),
        BackoffType = DelayBackoffType.Exponential,
        UseJitter = true,
        ShouldHandle = MassTransitTransientErrors.IsTransient,
    })
    .AddTimeout(TimeSpan.FromSeconds(10)));

public class OrderService(ResilientBus bus)
{
    public Task PlaceOrderAsync(Order order, CancellationToken ct)
        => bus.PublishAsync(new OrderPlaced { OrderId = order.Id }, ct);
}

API reference

Member Description
ResilientBus.Inner The underlying IBus
PublishAsync<T>(message, ct) Publishes a message through the pipeline
PublishAsync<T>(message, pipe, ct) Publishes with a pipe configuration through the pipeline
SendAsync<T>(address, message, ct) Sends to an endpoint through the pipeline
ExecuteAsync<T>(operation, ct) Runs any IBus operation through the pipeline
MassTransitTransientErrors.IsTransient PredicateBuilder for RequestTimeoutException, TimeoutException, HttpRequestException, TaskCanceledException
bus.WithPolly(pipeline) Wraps IBus with a pre-built pipeline
bus.WithPolly(configure) Builds pipeline inline and wraps the bus
services.AddPollyMassTransit(configure) DI registration (requires IBus in DI)

Target frameworks

.NET 6 ✅ · .NET 8 ✅ · .NET 9 ✅

Package Downloads Description
PollyHealthChecks Downloads ASP.NET Core health checks for Polly v8 circuit breakers — expose circuit-breaker state (Closed, HalfOpen, Open, Isolated) as /health endpoint responses
PollyBackoff Downloads Backoff delay strategies for Polly v8 resilience pipelines
PollyGrpc Downloads Polly v8 resilience interceptor for gRPC
PollyEFCore Downloads Polly v8 resilience pipelines for Entity Framework Core — wrap every EF Core query and SaveChanges with retry, timeout and circuit-breaker via a single AddPollyResilience() call
PollyRabbitMQ Downloads Polly v8 resilience for RabbitMQ.Client v7+ — retry, circuit-breaker, and timeout for IChannel operations, with built-in RabbitMqTransientErrors predicate covering AlreadyClosedException, BrokerUnreachableException, OperationInterruptedException, and ConnectFailureException
PollyMailKit Downloads Polly v8 resilience pipelines for MailKit — retry, timeout, and circuit-breaker for SmtpClient.SendAsync and any MailKit SMTP operation
PollyNpgsql Downloads Polly v8 resilience pipelines for Npgsql (PostgreSQL) — retry, timeout, and circuit-breaker for NpgsqlConnection queries and commands, plus a built-in PostgresTransientErrors predicate covering all common PostgreSQL transient SQLSTATE codes
PollyOpenAI Downloads Polly v8 resilience for OpenAI and Azure OpenAI API calls
PollyAzureEventHub Downloads Polly v8 resilience pipelines for Azure Event Hubs — retry, timeout, and circuit-breaker for EventHubProducerClient and EventHubConsumerClient
PollySignalR Downloads Polly v8 reconnect policy for SignalR
PollyHangfire Downloads Polly v8 resilience pipelines for Hangfire — retry, timeout, and circuit-breaker for IBackgroundJobClient.Enqueue and Schedule
PollyCosmosDb Downloads Polly v8 resilience pipelines for Azure Cosmos DB — retry, timeout, and circuit-breaker for Container operations, plus a built-in CosmosTransientErrors predicate covering rate limiting (429), timeouts (408), partition failovers (410), and service unavailability (503)
PollySendGrid Downloads Polly v8 resilience pipelines for SendGrid — retry, timeout, and circuit-breaker for ISendGridClient.SendEmailAsync
PollyMongo Downloads Polly v8 resilience pipelines for MongoDB.Driver — wrap Find, InsertOne, UpdateOne, DeleteOne and other IMongoCollection calls with retry, timeout, circuit-breaker, and more using a single ResilientMongoCollection decorator
PollyDapper Downloads Polly v8 resilience pipelines for Dapper — wrap QueryAsync, ExecuteAsync, and other Dapper calls with retry, timeout, circuit-breaker, and more using a single ResilientDbConnection decorator
PollyMediatR Downloads Polly v8 resilience pipelines for MediatR — add retry, timeout, circuit-breaker, rate-limiting, hedging, and chaos engineering to any MediatR request handler with a single line of DI registration
PollySqlClient Downloads Polly v8 resilience pipelines for Microsoft.Data.SqlClient (SQL Server and Azure SQL) — retry, timeout, and circuit-breaker for SqlConnection queries and commands, plus a built-in SqlServerTransientErrors predicate covering all common SQL Server and Azure SQL transient error numbers
PollyAzureQueueStorage Downloads Polly v8 resilience pipelines for Azure Queue Storage — retry, timeout, and circuit-breaker for Azure.Storage.Queues QueueClient
PollyRedis Downloads Polly v8 resilience for StackExchange.Redis
PollyAzureServiceBus Downloads Polly v8 resilience for Azure Service Bus — retry, circuit breaker, and timeout for sending and receiving messages
PollyAzureBlob Downloads Polly v8 resilience pipelines for Azure Blob Storage — wrap BlobClient and BlobContainerClient operations with retry, timeout, circuit-breaker, and more using ResilientBlobClient and ResilientBlobContainerClient decorators
PollyKafka Downloads Polly v8 resilience for Confluent.Kafka — retry, circuit breaker, and timeout for producers and consumers
PollyAzureTableStorage Downloads Polly v8 resilience pipelines for Azure Table Storage — retry, timeout, and circuit-breaker for Azure.Data.Tables TableClient

💼 Need .NET consulting?

The author of this package is available for consulting on Polly v8 resilience, Azure cloud architecture, and clean .NET design.

→ solidqualitysolutions.com · LinkedIn

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 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
1.0.2 206 8/7/2026
1.0.1 142 7/7/2026
1.0.0 136 6/24/2026

1.0.1: Fix package icon (was showing an incorrect/placeholder image). 1.0.0: Initial release. ResilientBus wraps IBus in a Polly v8 ResiliencePipeline for producer-side resilience. Includes MassTransitTransientErrors predicate covering RequestTimeoutException, TimeoutException, HttpRequestException, and TaskCanceledException. Supports net6.0, net8.0, and net9.0.