Skip to main content

Yield

The Yield task temporarily yields control over the workflow by pausing the execution until it is explicitly resumed using the sync or async signal endpoints, typically in response to external conditions or events.

It is similar to the Wait task, which also introduces a pause point in a workflow. However, unlike the Wait task, the Yield task must be explicitly completed using the sync or async signal endpoints and supports passing data back into the workflow when resumed. This enables workflows to continue in flight with updated inputs.

Task parameters

Configure these parameters for the Yield task.

ParameterDescriptionRequired/Optional
inputParametersThe input parameters for the Yield task, which can be fixed or passed as a variable.Required.

Caching parameters

You can cache the task outputs using the following parameters. Refer to Caching Task Outputs for a full guide.

ParameterDescriptionRequired/Optional
cacheConfig.ttlInSecondThe time to live in seconds, which is the duration for the output to be cached.Required if using cacheConfig.
cacheConfig.keyThe cache key is a unique identifier for the cached output and must be constructed exclusively from the task’s input parameters.
It can be a string concatenation that contains the task’s input keys, such as ${uri}-${method} or re_${uri}_${method}.
Required if using cacheConfig.

Schema parameters

You can enforce input/output validation for the task using the following parameters. Refer to Schema Validation for a full guide.

ParameterDescriptionRequired/Optional
taskDefinitiom.enforceSchemaWhether to enforce schema validation for task inputs/outputs. Set to true to enable validation.Optional.
taskDefinition.inputSchemaThe name and type of the input schema to be associated with the task.Required if enforceSchema is set to true.
taskDefinition.outputSchemaThe name and type of the output schema to be associated with the task.Required if enforceSchema is set to true.

Other generic parameters

Here are other parameters for configuring the task behavior.

ParameterDescriptionRequired/Optional
optionalWhether the task is optional.
If set to true, the workflow continues to the next task even if this task fails or remains incomplete.
Optional.

Task configuration

This is the task configuration for a Yield task.

   {
"name": "yield",
"taskReferenceName": "yield_ref",
"type": "YIELD",
"inputParameters": {
"key": "value"
}
}

Task output

The task returns the output passed through the sync or async signal endpoints. This output can include updated values provided by an external system, allowing workflows to continue with new data injected mid-execution. For example:

{
"taskOutput": "Output passed through the API"
}

Adding a Yield task in UI

To add a Yield task:

  1. In your workflow, select the (+) icon and add a Yield task.
  2. Configure the Input parameters.

Adding yield task

Examples

Here are some examples for using the Yield task.

Using the Yield task in a workflow

To demonstrate the Yield task, consider the following workflow that contains a Yield task:

{
"name": "http_yield_signal_test",
"description": "http_yield_signal_test",
"version": 1,
"tasks": [
{
"name": "http",
"taskReferenceName": "http_ref",
"inputParameters": {
"uri": "https://orkes-api-tester.orkesconductor.com/api",
"method": "GET",
"accept": "application/json",
"contentType": "application/json",
"encode": true
},
"type": "HTTP"
},
{
"name": "yield",
"taskReferenceName": "simple_ref_1",
"inputParameters": {},
"type": "YIELD"
}
],
"schemaVersion": 2
}

In this example:

  • The workflow begins by executing an HTTP task.
  • After the HTTP task is completed, it proceeds to the Yield task.
  • The workflow is now paused, and the Yield task waits to be signaled.

Let’s signal this task asynchronously using the endpoint POST /api/tasks/{workflowId}/{status}/signal. An example API request:

curl -X 'POST' \
'https://developer.orkescloud.com/api/tasks/fd7s37423ca7-5002-11f0-9613-0e9a9f41f671/COMPLETED/signal' \
-H 'accept: */*' \
-H 'X-Authorization: <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"taskOutPut": "Output passed using the API"
}'

After calling this endpoint, return to the workflow execution to verify that the Yield task has been successfully signaled, with the output set through the API.

Sample execution with Yield task completed