CloudFlow allows you to integrate CloudFlow as a node into a workflow. A flow triggers one or more child flows. This topic describes the sample code, parameters, return value, integration modes, and errors when CloudFlow is integrated with CloudFlow.
Sample code
The following code provides an example on how CloudFlow is integrated with CloudFlow.
Type: StateMachine
Name: MyWorkflow
SpecVersion: v1
StartAt: StartExecution
States:
- Type: Task
Name: StartExecution
Action: FNF:StartExecution
TaskMode: RequestComplete
Description: an example of workflow invocation
Parameters:
resourceArn: acs:fnf:cn-hangzhou::flow/test-workflow
executionName: theExecutionName
input:
key: value1
End: true
Description of fields in the preceding code:
Action: Set the value to
FNF:StartExecution.TaskMode: Set the value to RequestComplete, WaitForSystemCallback, or WaitForCustomCallback.
Name and Description: Specify a name and description that are suitable for the business.
Parameter description
Parameter | Required | Description | Example |
resourceArn | Yes | The Alibaba Cloud Resource Name (ARN) of the workflow. You can obtain the ARN from the workflow details page in the CloudFlow console. Note You cannot invoke a child flow of a workflow across regions. | acs:fnf:::flow/test-workflow |
executionName | No | The name of the execution that you use each time you execute the workflow.
| test-execution-name |
input | No | The business data input of the workflow. The value must be an object. | |
Return value
The return value of the request is encapsulated in a JSON object. Example:
{
"FlowName": "test-workflow",
"ExecutionName": "36cc6107-26cc-495f-b80b-d9fadff13fdd",
"RequestID": "12423452346y345634"
}Execution mode
When you integrate CloudFlow with CloudFlow, the RequestComplete, WaitForSystemCallback, and WaitForCustomCallback service integration modes can be used.
RequestComplete
After the workflow initiates a child flow invocation, the current task is considered complete when the request for starting the next flow is complete.
WaitForCustomCallback
After the workflow initiates a child flow invocation, the workflow passes a callback token to the downstream flow, and the parent flow enters the Pending state. After you use the assigned token to call back the ReportTaskSucceeded or ReportTaskFailed API operation and report the execution result, the parent flow advances.
To obtain a unique token for each execution in the downstream flow, you must define a token parameter, as shown in the following code.
Type: StateMachine
Name: MyWorkflow
SpecVersion: v1
StartAt: StartExecution
States:
- Type: Task
Name: StartExecution
Action: FNF:StartExecution
TaskMode: RequestComplete
Description: an example of workflow invocation
Parameters:
resourceArn: acs:fnf:cn-hangzhou::flow/test-workflow
executionName: theExecutionName
input:
key: value1
token.$: $Context.Current.TaskToken
End: true
You must obtain the callback token from the token parameter. You can use the token.key parameter to specify the name of the token, and must use the $Context.Current.TaskToken expression to obtain the value of the token.
WaitForSystemCallback
After the workflow initiates a child flow initiation, the execution of the parent flow is automatically suspended. After the child flow is executed, the system automatically calls back the parent flow and continues subsequent steps.
Definition of errors
FNF.ResourceThrottled: The execution of the flow is throttled.
FNF.FlowNotExists: The workflow does not exist.
FNF.AccessDenied: The access is denied. The current user or role does not have the permissions to execute the flow.
FNF.ExecutionAlreadyExists: An execution that has the same name already exists.
FNF.InternalServerError: An internal server error occurs.