Polly Transient Fault handling UPDATE

I am now using Polly in production and it works awesomely. I followed the same fault handling policy noted on Hanselman’s blog about Polly.

var policy = Policy
.Handle<SqlException>()
.WaitAndRetry(5, retryAttempt => 
  TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), 
  (exception, span) =>
{
// Log transient error
} );

This is a decidedly easy way to implement an exponential back-off retry policy. On the first retry it waits 2 seconds, by the 5th and final retry it will wait 32 seconds. This means this sql call will wait up to 1 minute for attempting to complete the sql call (ignoring any time spent executing the sql call prior to a sql exception being raised)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s