Implementing Exponential Retry policy for ServiceBusTransientErrorDetectionStrategy

纵饮孤独 提交于 2019-12-11 02:24:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!