Azure / Azure/durabletask

Orchestration not resuming after exception thrown

Open
#761 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.7k
Forks
335
Avg merge
2d 23h
Merged PRs (30d)
6

Description

Apologies if I'm missing something obvious but I've been stuck for a little while playing around with the DTF. I have an orchestration setup which triggers a sub-orchestration. The sub orchestration schedules the GetUser activity 5 times. For testing purposes, if that activity receives an input of "throw" it will throw an exception. What I want to happen once an exception is from is for this orchestration to carry on after the point of failure. For example in the code below an exception will be thrown on the 3rd scheduled activity, when this exception is caught and logged I want it to then schedule the 4th task and so on... but instead the orchestration finishes once the first exception is thrown and doesn't schedule the remaining 2 activities which can be seen in the sequence diagram below. Please can someone point me in the right direction?

`public class TestOrch: TaskOrchestration
{
private string status = "";
private bool hasError = false;
private int errorCount = 0;
public OrchestrationContext Context { get; set; }

public override async Task RunTask(OrchestrationContext context, string input)
{
status = "running";
string UPN = "test.test@test.com";

try
{
await context.ScheduleTask(typeof(GetUser), UPN);
await context.ScheduleTask(typeof(GetUser), UPN);
await context.ScheduleTask(typeof(GetUser), "throw");
await context.ScheduleTask(typeof(GetUser), UPN);
await context.ScheduleTask(typeof(GetUser), "throw");
}
catch(Exception e)
{
logEvent(context, e.StackTrace, e.Message);
}

return true;
}

private void logEvent(OrchestrationContext context, string eventName, string eventMessage)
{
errorCount++;
hasError = true;
if (errorCount > 1)
{
status = $"{errorCount} activities have failed";
}
else
{
status = $"{errorCount} activity has failed";
}

//context.SendEvent(context.OrchestrationInstance, eventName, eventMessage);
}
public override string OnGetStatus()
{
return status;
}
}`
![image](https://user-images.githubusercontent.com/48337364/177538373-97784b95-b531-413c-9cee-fe28c13ee008.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.