Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Created June 3, 2018 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuka1984/c5779a0e3d070a4c6e2cf72fe46ae41d to your computer and use it in GitHub Desktop.
Save yuka1984/c5779a0e3d070a4c6e2cf72fe46ae41d to your computer and use it in GitHub Desktop.
[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