Skip to content

Feature Automatic Retries

Affan Dar edited this page Jan 30, 2015 · 1 revision

Any application that is consuming cloud services should be resilient to failures to some extent and hence client side retries become an important part of the implementation.

The framework provides alternative scheduling methods that perform retries on TaskActivity failures as per the supplied policy. This is useful if you want automatic retries e.g. for a TaskActivity that reads data from a webservice or performs an idempotent write to a database.

public class GetQuoteOrchestration : TaskOrchestration<string, string>
{
    public override async Task<string> RunTask(OrchestrationContext context, string input)
    {
        // retry every 10 seconds upto 5 times before giving up and bubbling up the exception
        RetryOptions retryOptions = new RetryOptions(TimeSpan.FromSeconds(10), 5);
        await context.ScheduleWithRetry<object>(typeof (GetQuote), retryOptions, null);
        return null;
    }
}