I have set automatic retry attempts to be default 3 (instead 10 as I believe is by default)
Hangfire.GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 })
but for some job I want to set attempts count to 0
public interface IMyJob
{
void DoSomething();
}
public class MyBackgroundJob : IMyJob
{
[AutomaticRetry(Attempts = 0)]
public void DoSomething()
{
}
}
Hangfire ingores this attribute and tries 3 attempts instead of 0.
It turns out that I need to put attribute on interface method
[AutomaticRetry(Attempts = 0)]
void DoSomething();
Most helpful comment
It turns out that I need to put attribute on interface method