Created
June 3, 2018 12:09
-
-
Save yuka1984/c5779a0e3d070a4c6e2cf72fe46ae41d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("OrderOrchestrator")] | |
public static async Task Order([OrchestrationTrigger]DurableOrchestrationContextBase context) | |
{ | |
var order = context.GetInput<OrderModel>(); | |
await context.CallActivityAsync("InsertToRepository" , order); | |
while (true) | |
{ | |
try | |
{ | |
await context.CallActivityWithRetryAsync("CallRemoteService", RetryOptions, order); | |
} | |
catch | |
{ | |
await context.CallActivityAsync("CallRemoteServiceFailReport", order); | |
var limitTime = context.CurrentUtcDateTime.AddDays(5); | |
var timer = context.CreateTimer<bool>(limitTime, false, CancellationToken.None); | |
var instract = context.WaitForExternalEvent<bool>("RetryCallRemoteServiceInstract"); | |
var retry = await Task.WhenAny(timer, instract); | |
if (retry.Result) | |
{ | |
continue; | |
} | |
else | |
{ | |
await context.CallActivityAsync("RollBackRepository", order); | |
// await context.CallActivityAsync("SendFailedMail", order); | |
} | |
} | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment