Skip to content

How to terminate sub-orchestrations ? #139

Description

@gsimardimt

How can we terminate sub-orchestrations in isolated process ? By reading issue #4, I understand there is no plan to return an instance history. What would be the replacement for the following code ?

[FunctionName(nameof(Orchestration_StopInstance))]
public static async Task<IActionResult> Orchestration_StopInstance(
    [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "orchestration/stop/{instanceId}")] HttpRequestMessage req,
    [DurableClient] IDurableOrchestrationClient orchestrationClient,
    string instanceId
)
{
    try
    {
        var durableOrchestrationStatus = await orchestrationClient.GetStatusAsync(instanceId, true, false, false);

        foreach (var subInstanceId in durableOrchestrationStatus.History.Select(t => t["InstanceId"]).Where(t => t != null))
        {
            await Orchestration_StopInstance(req, orchestrationClient, subInstanceId.ToString());
        }

        await orchestrationClient.TerminateAsync(instanceId, "Stopped");

        return new NoContentResult();
    }
    catch (Exception ex)
    {
        return new JsonResult(new Response(ex.Message.Trim())) { StatusCode = (int)HttpStatusCode.InternalServerError };
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions