本系列基于 Conductor
release v3.5.2
1. 概述
系統(tǒng)任務(wù)是 Conductor 內(nèi)部執(zhí)行的任務(wù),不需要 Worker 來實行執(zhí)行。本文介紹系統(tǒng)任務(wù)(HTTP,EVENT,INLINE,JQ)如何被執(zhí)行。注:不包含系統(tǒng)操作符Switch,DoWhile,SetVariable
2.WorkflowSystemTask
所有的系統(tǒng)任務(wù)都繼承WorkflowSystemTask。在 Conductor 系統(tǒng)啟動時SystemTaskRegistry所有WorkflowSystemTask加載進來,后續(xù)可以通過SystemTaskRegistry#isSystemTask方法判斷是否為系統(tǒng)任務(wù)從而執(zhí)行系統(tǒng)任務(wù)邏輯。
WorkflowSystemTask#start
Start the task execution.
Called only once, and first, when the task status is SCHEDULED.
第一次執(zhí)行任務(wù)時調(diào)用,且只調(diào)用一次
WorkflowSystemTask#execute
"Execute" the task.
Called after {@link #start(WorkflowModel, TaskModel, WorkflowExecutor)}, if the task
status is not terminal. Can be called more than once.
在start方法后執(zhí)行,可以被執(zhí)行多次
3.調(diào)用過程
入口WorkflowExecutor#decide。在該方法里,根據(jù)workflowId獲取接下來要調(diào)度的任務(wù)。
第1327行 stateChanged = scheduleTask(workflow, tasksToBeScheduled) || stateChanged;
scheduleTask 方法時執(zhí)行調(diào)度邏輯。
第1715行 List<TaskModel> systemTasks = tasks.stream() .filter(task -> systemTaskRegistry.isSystemTask(task.getTaskType())) .collect(Collectors.toList());
把系統(tǒng)任務(wù)過濾出來,并在1740行執(zhí)行workflowSystemTask.start(workflow, task, this);