public static async Task DurableFunctionWithRetryFailingActivity( [OrchestrationTrigger] IDurableOrchestrationContext context) { using (var tracker = FuncRetryTracker.Track()) { await context.CallActivityWithRetryAsync( nameof(FailAtGivenCallNoActivity), new RetryOptions(TimeSpan.FromMilliseconds(1), 2) { }, new RetryingActivitySetup { TrackerId = tracker.Id, SucceedAtCallNo = -1 }); } }
public static Task FailAtGivenCallNoActivity([ActivityTrigger] IDurableActivityContext context) { var activitySetup = context.GetInput <RetryingActivitySetup>(); var tracker = FuncRetryTracker.GetTracker(activitySetup.TrackerId); tracker.TrackCall(nameof(FailAtGivenCallNoActivity)); var currentCallCount = tracker.GetCallCount(nameof(FailAtGivenCallNoActivity)); if (currentCallCount == activitySetup.SucceedAtCallNo) { return(Task.CompletedTask); } throw new Exception("Failing call no " + currentCallCount); }