本文介紹云工作流如何通過集成云工作流來觸發工作流執行。使用Operation狀態,functionRef.type配置為cloudflow:executeWorkflow。
基本概念
參數配置
| 參數名稱 | 是否必選 | 參數說明 | 示例值 |
|---|---|---|---|
| workflowName | 是 | 被調用工作流名稱 | demo1 |
| workflowType | 是 | 被調用工作流類型
| express |
| executionName | 否 | 工作流執行名稱 | test1 |
| workflowInput | 是 | 工作流執行輸入,JSON格式 |
|
| regionId | 是 | 被調用工作流所屬地域。 | bb9fdb42056f11eda1610242ac11000 |
返回值與模式
返回值
工作流的執行輸出詳細數據,示例如下:
{
"workflowExecuteID": "wi-fbf0ec82-18b8-4f22-9349-d07b685067b5",
"workflowExecuteInput": {
"k1": "v1"
},
"workflowExecuteName": "test1",
"workflowExecuteOutput": {
"k1": "v1"
},
"workflowExecuteStartTime": "2025-06-12T07:36:18.714089503Z",
"workflowExecuteStatus": "completed",
"workflowExecuteStopTime": "2025-06-12T07:36:18.733828607Z",
"workflowName": "express-demo"
}執行模式
云工作流集成工作流執行, 支持請求響應(RequestComplete)、等待系統回調(WaitForSystemCallback)和等待任務令牌(WaitForTaskToken)三種模式。執行模式詳細介紹可查看服務集成模式。
示例代碼與解析
對不同執行模式的工作流進行示例說明。
請求響應(RequestComplete)示例
specVersion: "0.8"
name: "standard-demo"
start: "ExecuteWorkflow"
states:
- name: "ExecuteWorkflow"
type: "Operation"
metadata: {}
stateDataFilter: {}
actions:
- retryRef: []
catchRef: []
functionRef:
type: "cloudflow:executeWorkflow"
arguments:
workflowName: "express-demo"
workflowType: "express"
executionName: "test1"
workflowInput:
k1: "v1"
regionId: "bb9fdb42056f11eda1610242ac110002"
actionExecuteMode: "RequestComplete"
end: true以上工作流定義解析如下:
type:固定為
Operation,標識這是一個Operation狀態。functionRef.type:固定為cloudflow:executeWorkflow。
functionRef.arguments: 工作流執行輸入參數, JSON格式。
actionExecuteMode:示例使用
RequestComplete,表示同步執行, 等待工作流執行結果。注意快速工作流僅支持RequestComplete模式。
等待任務令牌(WaitForTaskToken)示例
specVersion: "0.8"
name: "standard-demo"
start: "ExecuteWorkflow"
states:
- name: "ExecuteWorkflow"
type: "Operation"
metadata: {}
stateDataFilter: {}
actions:
- retryRef: []
catchRef: []
functionRef:
type: "cloudflow:executeWorkflow"
arguments:
workflowName: "standard-for-systemcallback"
workflowType: "standard"
executionName: "test1"
workflowInput:
k1: "v1"
taskToken: "{ $Context.taskToken }"
regionId: "bb9fdb42056f11eda1610242ac110002"
actionExecuteMode: "WaitForTaskToken"
end: true以上工作流定義解析如下:
type:固定為
Operation,標識這是一個Operation狀態。functionRef.type:固定為cloudflow:executeWorkflow。
functionRef.arguments: 工作流執行輸入參數, JSON格式; 另外在參數需要添加任務令牌
{ $Context.taskToken }輸入參數。actionExecuteMode:示例使用
WaitForTaskToken,表示等待任務令牌,僅標準工作流可設置。 當前狀態執行完成需要等待到用戶用戶獲取TaskToken后通過ReportTaskSuccess或ReportTaskFailureOpenApi觸發回調,繼續執行。
等待系統回調(WaitForSystemCallback)示例
specVersion: "0.8"
name: "standard-demo"
start: "ExecuteWorkflow"
states:
- name: "ExecuteWorkflow"
type: "Operation"
metadata: {}
stateDataFilter: {}
actions:
- retryRef: []
catchRef: []
functionRef:
type: "cloudflow:executeWorkflow"
arguments:
workflowName: "standard-for-systemcallback"
workflowType: "standard"
executionName: "test1"
workflowInput:
k1: "v1"
regionId: "bb9fdb42056f11eda1610242ac110002"
actionExecuteMode: "WaitForSystemCallback"
end: true以上工作流定義解析如下:
type:固定為
Operation,標識這是一個Operation狀態。functionRef.type:固定為cloudflow:executeWorkflow。
functionRef.arguments: 工作流執行輸入參數, JSON格式。
actionExecuteMode:示例使用
WaitForSystemCallback,表示等待系統回調, 僅標準工作流可設置。被調用標準工作流執行后,無需用戶通過openapi回調taskToken通知被調用工作流執行完成。被調用工作流完成后,系統自動回調,更新ExecuteWorkflow狀態并繼續執行。