You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had searched in the DSIP and found no similar DSIP.
Motivation
Right now the sub workflow doesn't have a good implementation for failover/repeat running/pause/kill/recover, we should redesign this.
Design Detail
The sub workflow task represent a workflow.
When the task running, it will create a sub workflow instance, and track its state.
And once we trigger/pause/stop/recover the parent workflow we should trigger/pause/stop/recover the sub workflow instance.
Once the sub workflow task running, it will trigger a sub workflow instance. We will use SubWorkflowLogicTaskRuntimeContext to store the sub workflow instance id, so once the task running, we will get the SubWorkflowLogicTaskRuntimeContext, and using the SubWorkflowLogicTaskRuntimeContext to calculate status.
When the sub workflow task running, we will trigger the sub workflow by the operation type.
privateSubWorkflowLogicTaskRuntimeContextinitializeSubWorkflowInstance() {
// todo: doFailover if the runtime context is not null and task is generated by failoverif (subWorkflowLogicTaskRuntimeContext == null) {
returntriggerNewSubWorkflow();
}
switch (workflowExecutionRunnable.getWorkflowInstance().getCommandType()) {
caseRECOVER_SUSPENDED_PROCESS:
returnrecoverFromSuspendTasks();
caseSTART_FAILURE_TASK_PROCESS:
returnrecoverFromFailedTasks();
default:
returntriggerNewSubWorkflow();
}
}
And when we pause/kill the task, we will pause/stop the sub workflow, once the sub workflow instance has been paused/stopped, we can get the status after track status.
@Overridepublicvoidpause() throwsMasterTaskExecuteException {
if (subWorkflowLogicTaskRuntimeContext == null) {
log.info("subWorkflowLogicTaskRuntimeContext is null cannot pause");
return;
}
finalIntegersubWorkflowInstanceId = subWorkflowLogicTaskRuntimeContext.getSubWorkflowInstanceId();
finalWorkflowInstancePauseResponsepauseResponse = applicationContext
.getBean(SubWorkflowControlClient.class)
.pauseWorkflowInstance(newWorkflowInstancePauseRequest(subWorkflowInstanceId));
if (pauseResponse.isSuccess()) {
log.info("Pause sub workflowInstance: id={}", subWorkflowInstanceId + " success");
} else {
log.info("Pause sub workflowInstance: id={} failed with response: {}", subWorkflowInstanceId,
pauseResponse);
}
}
@Overridepublicvoidkill() throwsMasterTaskExecuteException {
if (subWorkflowLogicTaskRuntimeContext == null) {
log.info("subWorkflowLogicTaskRuntimeContext is null cannot kill");
return;
}
finalIntegersubWorkflowInstanceId = subWorkflowLogicTaskRuntimeContext.getSubWorkflowInstanceId();
finalWorkflowInstanceStopResponsestopResponse = applicationContext
.getBean(SubWorkflowControlClient.class)
.stopWorkflowInstance(newWorkflowInstanceStopRequest(subWorkflowInstanceId));
if (stopResponse.isSuccess()) {
log.info("Kill sub workflowInstance: id={}", subWorkflowInstanceId + " success");
} else {
log.info("Kill sub workflowInstance: id={} failed with response: {}", subWorkflowInstanceId, stopResponse);
}
}
Search before asking
Motivation
Right now the sub workflow doesn't have a good implementation for failover/repeat running/pause/kill/recover, we should redesign this.
Design Detail
The sub workflow task represent a workflow.
When the task running, it will create a sub workflow instance, and track its state.
And once we trigger/pause/stop/recover the parent workflow we should trigger/pause/stop/recover the sub workflow instance.
Once the sub workflow task running, it will trigger a sub workflow instance. We will use SubWorkflowLogicTaskRuntimeContext to store the sub workflow instance id, so once the task running, we will get the SubWorkflowLogicTaskRuntimeContext, and using the SubWorkflowLogicTaskRuntimeContext to calculate status.
When the sub workflow task running, we will trigger the sub workflow by the operation type.
And when we pause/kill the task, we will pause/stop the sub workflow, once the sub workflow instance has been paused/stopped, we can get the status after track status.
Compatibility, Deprecation, and Migration Plan
Compatibility with old version.
Test Plan
Test by Master IT.
Code of Conduct
The text was updated successfully, but these errors were encountered: