feat: the workflow instance whose max instance number is less than or equal to zero is always allowed to be executed

This commit is contained in:
Echo009 2021-03-03 14:26:50 +08:00
parent 21291b34cb
commit 8f9e53ed83

View File

@ -162,12 +162,14 @@ public class WorkflowInstanceManager {
log.info("[Workflow-{}|{}] workflowInstance({}) needn't running any more.", wfInfo.getId(), wfInstanceId, wfInstanceInfo); log.info("[Workflow-{}|{}] workflowInstance({}) needn't running any more.", wfInfo.getId(), wfInstanceId, wfInstanceInfo);
return; return;
} }
// 最大实例数量 <= 0 表示不限制
// 并发度控制 if (wfInfo.getMaxWfInstanceNum() > 0) {
int instanceConcurrency = workflowInstanceInfoRepository.countByWorkflowIdAndStatusIn(wfInfo.getId(), WorkflowInstanceStatus.GENERALIZED_RUNNING_STATUS); // 并发度控制
if (instanceConcurrency > wfInfo.getMaxWfInstanceNum()) { int instanceConcurrency = workflowInstanceInfoRepository.countByWorkflowIdAndStatusIn(wfInfo.getId(), WorkflowInstanceStatus.GENERALIZED_RUNNING_STATUS);
onWorkflowInstanceFailed(String.format(SystemInstanceResult.TOO_MANY_INSTANCES, instanceConcurrency, wfInfo.getMaxWfInstanceNum()), wfInstanceInfo); if ( instanceConcurrency > wfInfo.getMaxWfInstanceNum()) {
return; onWorkflowInstanceFailed(String.format(SystemInstanceResult.TOO_MANY_INSTANCES, instanceConcurrency, wfInfo.getMaxWfInstanceNum()), wfInstanceInfo);
return;
}
} }
try { try {