I have a requirement to manually configure the time between retries. I was not able to find the way for it.
But I found a code from https://github.com/HangfireIO/Hangfire/blob/master/src/Hangfire.Core/AutomaticRetryAttribute.cs
which schedule job after maximum number of retries are finished.
public static readonly int DefaultRetryAttempts = 10;
I have changed above property DefaultRetryAttemts
to 3
instead of 10
then also it is taking 10 retries for a single job
'Retry attempt 7 of 10: Error while importing data'
My requirement is to have 5 Retry Attempts and provide 20 minutes delay after each retry.
This feature has been merged to version 1.7 beta. For whoever wants to get the feature early, copy the new AutomaticRetryAttribute code to your project, rename it to AutomaticRetryExtAttribute and apply both attributes to your job.
[AutomaticRetry(Attempts = 0)] is applied to prevent it from rescheduling jobs upon failure. It is important because we want AutomaticRetryExt to handle the rescheduling instead.
[AutomaticRetry(Attempts = 0)]
[AutomaticRetryExt(Attempts = 30, DelaysInSeconds=new int[] { 300 })]
public static async Task Download(string fileName)
{
}