1.7 KiB
Child Workflows
This tutorial demonstrates how a workflow can call child workflows that are part of the same application. Child workflow can be used to break up large workflows into smaller, re-usable parts. For more information about child workflows see the Dapr docs.
Inspect the code
Open the ParentWorkflow.cs
file in the tutorials/workflow/csharp/child-workflows/ChildWorkflows
folder. This file contains the definition for the workflow.
The workflow iterates over the input array and schedules the ChildWorkflow
for each of the input elements. The ChildWorkflow
contains a sequence of two activities.
Parent workflow
graph LR
SW((Start
Workflow))
subgraph for each word in the input
GWL[Call child workflow]
end
ALL[Wait until all tasks
are completed]
EW((End
Workflow))
SW --> GWL
GWL --> ALL
ALL --> EW
Child workflow
graph LR
SW((Start
Workflow))
A1[Activity1]
A2[Activity2]
EW((End
Workflow))
SW --> A1
A1 --> A2
A2 --> EW
Run the tutorial
-
Use a terminal to navigate to the
tutorials/workflow/csharp/child-workflows
folder. -
Build the project using the .NET CLI.
dotnet build ./ChildWorkflows/
-
Use the Dapr CLI to run the Dapr Multi-App run file
dapr run -f .
-
Use the POST request in the
childworkflows.http
file to start the workflow. -
Use the GET request in the
childworkflows.http
file to get the status of the workflow. -
Stop the Dapr Multi-App run process by pressing
Ctrl+C
.