I have an orchestrator that calls an activity function to process customer Id's The output of this activity returns error ID's (if there are any) and I wish to reprocess these Id's by executing the activity again until there are no error id's (output is null).
Is it good practice to have a do loop for an orchestrator? How do I include a 5 min delay before each time the activity gets executed?
public static async Task<string> RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context, ILogger log)
{
log = context.CreateReplaySafeLogger(log);
dynamic errorOutput = null;
dynamic processCustomers = context.GetInput<dynamic>();
log = context.CreateReplaySafeLogger(log);
do
{
log.LogInformation("Calling activity");
errorOutput = await context.CallActivityAsync<dynamic>("GetCSPCustomerLicenses_Activity", processCustomers);
//Get customers to process from error object
processCustomers = errorOutput;
//Wait 5 minutes - how do I achieve this ?
} while (errorOutput != null);
return "Success";
}
Task.Wait, but a better pattern might be to fail the function and do the retry at the root caller, if it is a queue you can requeue. the reason is that if you have multiple functions calling each other and each of them makes a retry, then you will have exponential waits. - Carlos Garcia