Azure / Azure/durabletask

Recommendation to implement cancellation of a TaskActivity

Open
#942 5 comments 4 reactions 0 assignees View on GitHub
enhancement question
Dominant language
C#
Stars
1.7k
Forks
335
Avg merge
2d 23h
Merged PRs (30d)
6

Description

Hello, we have the current setup of orchestration and activities:

```csharp

public class LongActivity: AsyncTaskActivity {
protected override async Task ExecuteAsync( TaskContext context, string input ) {
/// DO a pretty long task
return input;
}
}

public class ParallelOrchestration : TaskOrchestration {
public override async Task RunTask( OrchestrationContext ctx, string _ ){
var task1 = ctx.ScheduleActivity( "foo" );
var task2= ctx.ScheduleActivity( "bar" );
await Task.WhenAll( task1, task2);
}
}
```
With `TaskHubClient` we can start the orchestration, and we want to be able to abort it, currently, we "terminate" the orchestration:

```csharp

TaskHubClient client = /// create client
var orchestrationInstance = await client.CreateOrchestrationAsync( typeof( ParallelOrchestration), "input");

/// do other stuffs

/// terminate the orchestration
await client.TerminateInstanceAsync( orchestrationInstance);
```

The ADTF framework will indeed terminate the orchestration, but the task activity are still on going. These activities are pretty long to execute and, unfortunately, we cannot divide them in smaller activities. But they can take a `cancellationToken`.

Is there any recommendation on how to implement cancellation of activities ?
Bonus question: any recommendation on how to ensure that a sub-orchestration is also cancelled/terminated if the parent orchestration is terminated ?

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.