本系列基于 Conductor
release v3.5.2
1. 概述
系统任务是 Conductor 内部执行的任务,不需要 Worker 来实行执行。本文介绍系统任务(HTTP,EVENT,INLINE,JQ)如何被执行。注:不包含系统操作符Switch,DoWhile,SetVariable
2.WorkflowSystemTask
所有的系统任务都继承WorkflowSystemTask
。在 Conductor 系统启动时SystemTaskRegistry
所有WorkflowSystemTask
加载进来,后续可以通过SystemTaskRegistry#isSystemTask
方法判断是否为系统任务从而执行系统任务逻辑。
WorkflowSystemTask#start
Start the task execution.
Called only once, and first, when the task status is SCHEDULED.
第一次执行任务时调用,且只调用一次
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方法后执行,可以被执行多次
3.调用过程
入口WorkflowExecutor#decide
。在该方法里,根据workflowId获取接下来要调度的任务。
第1327行
stateChanged = scheduleTask(workflow, tasksToBeScheduled) || stateChanged;
scheduleTask 方法时执行调度逻辑。
第1715行
List<TaskModel> systemTasks = tasks.stream() .filter(task -> systemTaskRegistry.isSystemTask(task.getTaskType())) .collect(Collectors.toList());
把系统任务过滤出来,并在1740行
执行workflowSystemTask.start(workflow, task, this);
网友评论