hotfix - 修复生成环境中发现的, 通过引擎的异步任务执行过程中抛出的 WorkflowEngineException 处理

This commit is contained in:
wangli 2024-06-26 15:59:55 +08:00
parent 355eed83f3
commit 771766f917
2 changed files with 36 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import cn.axzo.workflow.core.engine.job.AsyncRejectTaskJobHandler;
import cn.axzo.workflow.core.engine.job.AsyncTransferUserTaskJobHandler;
import cn.axzo.workflow.core.engine.job.exception.handle.CustomAsyncJobLogClearTraceExceptionHandler;
import cn.axzo.workflow.core.engine.job.exception.handle.CustomAsyncRunnableExceptionExceptionHandler;
import cn.axzo.workflow.core.engine.job.exception.handle.CustomWorkflowEngineExceptionHandler;
import cn.axzo.workflow.core.engine.persistence.CustomMybatisHistoricProcessInstanceDataManager;
import cn.axzo.workflow.core.service.BpmnProcessActivityService;
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
@ -88,6 +89,7 @@ public class FlowableConfiguration {
configuration.setEnableVerboseExecutionTreeLogging(enableVerboseExecutionTreeLogging);
configuration.setCustomAsyncRunnableExecutionExceptionHandlers(Lists.newArrayList(
new CustomAsyncJobLogClearTraceExceptionHandler(),
new CustomWorkflowEngineExceptionHandler(),
new CustomAsyncRunnableExceptionExceptionHandler()));
configuration.setCommandContextFactory(new CustomCommandContextFactory());
};

View File

@ -0,0 +1,34 @@
package cn.axzo.workflow.core.engine.job.exception.handle;
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
import lombok.extern.slf4j.Slf4j;
import org.flowable.job.api.JobInfo;
import org.flowable.job.service.JobServiceConfiguration;
import org.flowable.job.service.impl.asyncexecutor.AsyncRunnableExecutionExceptionHandler;
import java.util.Objects;
/**
* 解决异步任务执行过程中, 抛出的 WorkflowEngineException 正常的业务异常.
*
* @author wangli
* @since 2024/6/26 15:53
*/
@Slf4j
public class CustomWorkflowEngineExceptionHandler implements AsyncRunnableExecutionExceptionHandler {
@Override
public boolean handleException(JobServiceConfiguration jobServiceConfiguration, JobInfo job, Throwable e) {
if (getRootCause(e).getClass().isAssignableFrom(WorkflowEngineException.class)) {
log.warn("AsyncApproveTaskJobHandler execute exception info: {}", e.getMessage(), e);
return true;
}
return false;
}
private Throwable getRootCause(Throwable throwable) {
while (Objects.nonNull(throwable.getCause())) {
throwable = throwable.getCause();
}
return throwable;
}
}