Set Time increase for the custom exception from custom exception policy

Any hep how do I set the Time increase value for the custom exception from the custom exception policy below?

Thanks, Pon

Hi Pon,

Not sure I understand your question entirely. The comment in your code snippets says “do a fixed backoff of 5 seconds” which would boil down to

return RecoverabilityAction.DelayedRetry(TimeSpan.FromSeconds(5));

this is similar to the partial customization example we have on our documentation page, except you are using SqlException instead of MyOtherBusinessException`

Regards,
Daniel

Hey @danielmarbach,

Thanks for the reply. This is the default delay retry policy: the first delay retry occurs after 10 seconds, the second after 20 seconds, and the third after 30 seconds. We can see that the time to increase is 10 seconds. Under the above policy, a retry occurs every minute. The increase is not happening. How do I configure that?

Thanks, Pon

Hi @ponkarthik87

Ok I think I understand now. What you would like is something like the default policy for SqlExceptions starting with 1 minute and then an increasing timeout of 10 seconds over the delayed retry attempts. Is that correct?

In the simplest form you could essentially add 1 minute to whatever is returned by the delayed retry action returned by the default policy

    if (action is DelayedRetry delayedRetryAction &&
        context.Exception is SqlException)
    {
        return RecoverabilityAction.DelayedRetry(delayedRetryAction.Delay + TimeSpan.FromSeconds(60));
    }

then it takes whatever defaults you have configured but extends it with one minute on top of that.

If that approach is too simplistic, then things will be a bit more tricky. You need to mimic what is done in the default policy.

Hope that helps

Daniel

Thank you @danielmarbach

1 Like