You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Azure Event Hubs is a mission-critical ingestion pipeline — dropped events mean lost data. EventHubsException.IsTransient tells you exactly which errors are safe to retry; this library wires that directly into Polly v8:
Problem
Solution
EventHubsException where IsTransient = true (throttling, service busy, connection dropped)
Caught by EventHubsTransientErrors.IsTransient
TimeoutException — service took too long to respond
Caught by EventHubsTransientErrors.IsTransient
TaskCanceledException — network timeout during transit
usingAzure.Messaging.EventHubs;usingAzure.Messaging.EventHubs.Producer;usingPolly;usingPolly.Retry;varproducer=newEventHubProducerClient(connectionString,"telemetry");varresilient=producer.WithPolly(p =>p.AddRetry(newRetryStrategyOptions{MaxRetryAttempts=3,Delay=TimeSpan.FromSeconds(2),BackoffType=DelayBackoffType.Exponential,UseJitter=true,ShouldHandle=EventHubsTransientErrors.IsTransient,}));// Send a batchusingvarbatch=awaitresilient.CreateBatchAsync();foreach(varreadinginsensorReadings)batch.TryAdd(newEventData(JsonSerializer.SerializeToUtf8Bytes(reading)));awaitresilient.SendAsync(batch);
2. Dependency injection
// Program.cs / Startup.csbuilder.Services.AddPollyAzureEventHub(connectionString,"telemetry",
pipeline =>pipeline.AddRetry(newRetryStrategyOptions{MaxRetryAttempts=3,Delay=TimeSpan.FromSeconds(2),BackoffType=DelayBackoffType.Exponential,UseJitter=true,ShouldHandle=EventHubsTransientErrors.IsTransient,}).AddTimeout(TimeSpan.FromSeconds(30)));// Inject ResilientEventHubProducerClient into your servicespublicclassTelemetryIngester(ResilientEventHubProducerClientproducer){publicasyncTaskSendAsync(IEnumerable<Reading>readings,CancellationTokenct){usingvarbatch=awaitproducer.CreateBatchAsync(ct);foreach(varrinreadings)batch.TryAdd(newEventData(JsonSerializer.SerializeToUtf8Bytes(r)));awaitproducer.SendAsync(batch,ct);}}
// Use in any Polly strategy:ShouldHandle=EventHubsTransientErrors.IsTransient
Condition
Why it's transient
EventHubsException (IsTransient = true)
Service throttling, quota exceeded, brief outage — SDK-designated as safe to retry
EventHubsException (IsTransient = false)
Auth failure, bad request — not retried
TimeoutException
Operation timed out waiting for service response
TaskCanceledException
Network-level cancellation or timeout
Key differentiator:EventHubsException.IsTransient is set by the Azure SDK team — this library exposes it directly as a Polly predicate, so your retry logic is always in sync with the SDK's own classification.
ASP.NET Core health checks for Polly v8 circuit breakers — expose circuit-breaker state (Closed, HalfOpen, Open, Isolated) as /health endpoint responses
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
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
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
Polly v8 resilience pipelines for Elastic.Clients.Elasticsearch 8+ — retry, timeout, and circuit-breaker for any Elasticsearch operation, plus a built-in ElasticTransientErrors predicate covering rate limiting (429), service unavailability (503), gateway timeouts (504), and connection failures
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)
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
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
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
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
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