问题
I am trying to implement Retry Policy for Service Bus transient error. I want my system to try exponentially like 1s, 2s, 4s, 8s, 16s, 32s, 64s, 128s.
private int minBackoffDelayInMilliseconds = 2000;
private int maxBackoffDelayInMilliseconds = 10000;
private int deltaBackoffInMilliseconds = 2000;
var defaultPolicy = new RetryPolicy<ServiceBusTransientErrorDetectionStrategy>(new ExponentialBackoff(maxRetries, TimeSpan.FromMilliseconds(minBackoffDelayInMilliseconds), TimeSpan.FromMilliseconds(maxBackoffDelayInMilliseconds), TimeSpan.FromMilliseconds(deltaBackoffInMilliseconds))
Does this look right ? and does this policy affect the system performance ?
回答1:
Here is a good article from the Azure CAT team that shows a couple of examples.
https://azure.microsoft.com/en-us/documentation/articles/best-practices-retry-service-specific/#service-bus-retry-guidelines
They suggest doing it like this:
namespaceManager.Settings.RetryPolicy = new RetryExponential(TimeSpan.FromSeconds(0.1),TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5), 3);
来源:https://stackoverflow.com/questions/37938849/implementing-exponential-retry-policy-for-servicebustransienterrordetectionstrat