I have a jobs and global config for retrying (10 retries)
I want to disable auto-retry for job if it throwed specific exception (see example)
public void DoJob()
{
try
{
// Do job
}
catch (NotImplementedException ex)
{
// Dont't retry job
}
catch (Exception ex)
{
// Log and retry
}
}
As a solution to this scenario, i use to exhaust the retries by setting the Job Parameter RetryCount to something that i know isn’t used by my jobs, like 9999, or you could use a bigger number (Int32.MaxValue) if you have jobs with such a high retry attempts, rsrsrs
For that, i’m injecting PerformContext on my job methods (using Dependency Injection), so:
public Task MytestMethod(PerformContext jobContext)
{
try
{
trySomething();
} catch (IrreoverableExceptionType ex) {
jobContext.SetJobParameter("RetryCount", 9999);
notifySomeone(ex);
throw;
} catch (OtherExceptions ex) {
doSomethingElse();
notifySomeone(ex);
throw;
}
don’t know if it’s the best way…