I am using C# ASP.NET Core 3.1 with Hangfire to schedule background jobs. By default if an exception occurs during the execution of the background job, there are 10 retry attempts. I am aware it is possible to use the AutomaticRetry
attribute to set that to 0, but I don't want to do that on every single background job. Instead I want the default to be 0 and to only specify it manually with the attribute in the very very rare case that I want it to be non-0. Thanks.
I used to do it like this in .Net Classic, I guess it should not be so different in .Net Core
// disable automatic retry if a job fails
Hangfire.GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute() { Attempts = 0 });