Created
September 16, 2020 17:30
-
-
Save marcduiker/5be7231212137c85d6827fb91159bd94 to your computer and use it in GitHub Desktop.
Escalate calls orchestrator with time out.
This file contains hidden or 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
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Extensions.DurableTask; | |
using Microsoft.Extensions.Logging; | |
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace DurableFunctions.Demo.DotNetCore.EscalateCalls | |
{ | |
public class EscalateCallsOrchestrator | |
{ | |
[FunctionName(nameof(EscalateCallsOrchestrator))] | |
public async Task Run( | |
[OrchestrationTrigger] IDurableOrchestrationContext context, | |
ILogger logger) | |
{ | |
var maxWaitTimePerCall = TimeSpan.FromMinutes(5); | |
await context.CallActivityAsync("MakeCall", "phonenumber1"); | |
// Orchestrator will wait until Call1 event is received or maxWaitTime is passed. | |
var resultCall1 = await context.WaitForExternalEvent<bool>("Call1", maxWaitTimePerCall, false); | |
if (!resultCall1) | |
{ | |
// Call1 has not been received within maxWaitTime. Let's try Call2. | |
await context.CallActivityAsync("MakeCall", "phonenumber2"); | |
// Orchestrator will wait until Call2 event is received or maxWaitTime is passed. | |
var resultCall2 = await context.WaitForExternalEvent<bool>("Call2", maxWaitTimePerCall, false); | |
if (!resultCall2) | |
{ | |
// Call2 has not been received within maxWaitTime. Let's try Call3. | |
await context.CallActivityAsync("MakeCall", "phonenumber3"); | |
// Orchestrator will wait until Call3 event is received or maxWaitTime is passed. | |
var resultCall3 = await context.WaitForExternalEvent<bool>("Call3", maxWaitTimePerCall, false); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment