diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessActivityServiceImpl.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessActivityServiceImpl.java index bec4239e5..00b769abc 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessActivityServiceImpl.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessActivityServiceImpl.java @@ -1,11 +1,11 @@ package cn.axzo.workflow.core.service.impl; +import cn.axzo.workflow.common.exception.WorkflowEngineException; import cn.axzo.workflow.common.model.request.bpmn.activity.BpmnActivityTimeoutCallbackDTO; import cn.axzo.workflow.common.model.request.bpmn.activity.BpmnActivityTimeoutTriggerDTO; import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceAbortDTO; import cn.axzo.workflow.common.model.request.bpmn.task.BpmnActivitySetAssigneeDTO; import cn.axzo.workflow.common.model.request.bpmn.task.BpmnActivityTriggerDTO; -import cn.axzo.workflow.common.exception.WorkflowEngineException; import cn.axzo.workflow.core.engine.cmd.CustomAbortProcessInstanceCmd; import cn.axzo.workflow.core.engine.cmd.CustomActivityTriggerAsyncCmd; import cn.axzo.workflow.core.engine.cmd.CustomActivityTriggerCmd; @@ -15,6 +15,7 @@ import cn.axzo.workflow.core.engine.cmd.CustomBusinessNodeTimeoutCallbackCmd; import cn.axzo.workflow.core.engine.cmd.CustomBusinessNodeTimeoutTriggerCmd; import cn.axzo.workflow.core.service.BpmnProcessActivityService; import cn.axzo.workflow.core.service.ExtAxHiTaskInstService; +import com.google.common.util.concurrent.Uninterruptibles; import lombok.extern.slf4j.Slf4j; import org.flowable.common.engine.impl.interceptor.CommandExecutor; import org.flowable.engine.RuntimeService; @@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import java.time.Duration; import java.util.Objects; import static cn.axzo.workflow.common.code.BpmnTaskRespCode.ACTIVITY_TRIGGER_NOT_EXISTS; @@ -48,10 +50,19 @@ public class BpmnProcessActivityServiceImpl implements BpmnProcessActivityServic @Transactional(rollbackFor = Exception.class) public void trigger(BpmnActivityTriggerDTO dto) { CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor(); - if (Boolean.TRUE.equals(dto.getAsync())) { - commandExecutor.execute(new CustomActivityTriggerAsyncCmd(dto)); - } else { - commandExecutor.execute(new CustomActivityTriggerCmd(dto)); + try { + if (Boolean.TRUE.equals(dto.getAsync())) { + commandExecutor.execute(new CustomActivityTriggerAsyncCmd(dto)); + } else { + commandExecutor.execute(new CustomActivityTriggerCmd(dto)); + } + } catch (WorkflowEngineException e) { + Uninterruptibles.sleepUninterruptibly(Duration.ofSeconds(2)); + if (Boolean.TRUE.equals(dto.getAsync())) { + commandExecutor.execute(new CustomActivityTriggerAsyncCmd(dto)); + } else { + commandExecutor.execute(new CustomActivityTriggerCmd(dto)); + } } }