Resilience & Error Handling Overview

Resilience features that recover from transient failures automatically and fail fast on the permanent ones.

Key Features

Retry Policies

Automatically retry failed tasks with configurable policies. Choose from built-in linear retry, implement custom exponential backoff, or integrate with Polly for advanced resilience patterns.

Learn more: Retry Policies

Exception Filtering

Configure which exceptions should trigger retries and which should fail immediately. Prevent wasting retry attempts on permanent errors while handling transient failures gracefully.

Learn more: Exception Filtering

OnRetry Callbacks

Get visibility into retry attempts with lifecycle callbacks. Track metrics, implement circuit breaker patterns, and debug intermittent failures.

Learn more: Retry Callbacks

Timeout Management

Prevent runaway tasks with flexible timeout configuration at global, per-handler, and per-queue levels.

Learn more: Timeout Management

Cancellation Support

Implement cooperative cancellation for graceful shutdown and resource cleanup using CancellationTokens.

Learn more: Cancellation Tokens

Graceful Shutdown

Handle application restarts gracefully with automatic task recovery and progress tracking.

Learn more: Graceful Shutdown

Error Observation

React to errors using lifecycle hooks for alerting, telemetry, and compensation workflows.

Learn more: Error Observation

Quick Examples

Basic Retry Policy

builder.Services.AddEverTask(opt =>
{
    // 3 retries (up to 4 executions) with 500ms delay between attempts
    opt.SetDefaultRetryPolicy(new LinearRetryPolicy(3, TimeSpan.FromMilliseconds(500)));
});

Exception Filtering

public class DatabaseTaskHandler : EverTaskHandler<DatabaseTask>
{
    public override IRetryPolicy? RetryPolicy => new LinearRetryPolicy(5, TimeSpan.FromSeconds(2))
        .HandleTransientDatabaseErrors(); // Only retry database-related errors
}

Timeout Configuration

public class QuickTaskHandler : EverTaskHandler<QuickTask>
{
    public override TimeSpan? Timeout => TimeSpan.FromSeconds(30);
}

Cancellation Token Usage

public override async Task Handle(MyTask task, CancellationToken cancellationToken)
{
    foreach (var item in task.Items)
    {
        cancellationToken.ThrowIfCancellationRequested();
        await ProcessItemAsync(item, cancellationToken);
    }
}

Next Steps

Start with Retry Policies to learn the basics, then explore:


Copyright © 2025 Giampaolo Gabba. Distributed under the APACHE 2.0 License.

This site uses Just the Docs, a documentation theme for Jekyll.