Users Pricing

forum

Home Forums How to configure custom retry policies and disable automatic retries in Hangfire? – MindStick

How to configure custom retry policies and disable automatic retries in Hangfire?

Manish Sharma 27 17 Sep 2026

In my ASP.NET Core application, some long-running background tasks fail due to transient network errors, while others fail due to unrecoverable business validation issues. By default, Hangfire retries failed jobs up to 10 times.

Applying Retry Attributes

I know I can use the AutomaticRetry attribute at the method level:

// Customize retry attempts and strategy for a specific method
[AutomaticRetry(Attempts = 3, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
public void ProcessPayment(int orderId)
{
    // Payment processing logic
    PaymentGateway.Charge(orderId);
}

Global Configuration Questions

I want to apply a default retry policy globally across all jobs while overriding it for specific background operations. How can I set a global retry attempt limit during registration in Program.cs? Also, how can I capture exceptions from a failed background job and send alert notifications to developers before the job is placed in the Deleted state?


0 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md