TERMINATE task can terminate the workflow with a given status and set the workflow's output with the provided value.
It can act as a
return statement for conditions where you simply want to terminate your workflow.
Use it when you want to terminate the workflow without continuing the execution.
For example, if you have a decision where the first condition is met, you want to execute some tasks, otherwise you want to finish your workflow.
TERMINATE task is configured with the following attributes inside
|workflowOutput||Any||Workflow output to be set|
|terminationReason||String||For failed tasks, this reason is recorded and passed to any configured
|output||Map||The content of
Terminate task is defined directly inside the workflow with type
Use with SWITCH
Let's consider the same example we had in Switch Task.
Suppose in a workflow, we have to take decision to ship the courier with the shipping service providers on the basis of input provided while running the workflow. If the input provided while running workflow does not match with the available shipping providers then the workflow will fail and return. If input provided matches then it goes ahead.
Here is a snippet that shows the default switch case terminating the workflow:
Workflow gets created as shown in the diagram.
- Include termination reason when terminating the workflow with failure status to make it easy to understand the cause.
- Include any additional details (e.g. output of the tasks, switch case etc) that helps understand the path taken to termination.