hotfix - 兼容处理批量处理时,正常的业务异常会让异步任务进入死信

This commit is contained in:
wangli 2024-06-27 21:04:15 +08:00
parent b80137164b
commit 6da057194a
3 changed files with 12 additions and 4 deletions

View File

@ -89,7 +89,7 @@ public class FlowableConfiguration {
configuration.setEnableVerboseExecutionTreeLogging(enableVerboseExecutionTreeLogging);
configuration.setCustomAsyncRunnableExecutionExceptionHandlers(Lists.newArrayList(
new CustomAsyncJobLogClearTraceExceptionHandler(),
// new CustomWorkflowEngineExceptionHandler(),
new CustomWorkflowEngineExceptionHandler(),
new CustomAsyncRunnableExceptionExceptionHandler()));
configuration.setCommandContextFactory(new CustomCommandContextFactory());
};

View File

@ -9,6 +9,7 @@ import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.repository.entity.ExtAxHiTaskInst;
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
import cn.axzo.workflow.core.service.converter.BpmnHistoricTaskInstanceConverter;
import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.Process;
import org.flowable.common.engine.impl.cfg.IdGenerator;
@ -69,6 +70,7 @@ import static org.flowable.task.api.Task.DEFAULT_PRIORITY;
* @author wangli
* @since 2023/12/22 10:59
*/
@Slf4j
public class CustomTaskHelper {
public static void addMultiTask(CommandContext commandContext, TaskEntity originTask,
@ -150,6 +152,7 @@ public class CustomTaskHelper {
BpmnFlowNodeType nodeType = BpmnMetaParserHelper.getNodeType(currentFlowElement).orElse(NODE_EMPTY);
//不包含对应的任务
if (!nodeTypes.contains(nodeType)) {
// log.warn(TASK_TYPE_MISMATCH.getMessage(), nodeType.getDesc(), nodeTypes.stream().map(BpmnFlowNodeType::getDesc).collect(Collectors.joining(",")));
throw new WorkflowEngineException(TASK_TYPE_MISMATCH, nodeType.getDesc(), nodeTypes.stream().map(BpmnFlowNodeType::getDesc).collect(Collectors.joining(",")));
}
}

View File

@ -18,9 +18,14 @@ import java.util.Objects;
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;
Throwable rootCause = getRootCause(e);
if (rootCause.getClass().isAssignableFrom(WorkflowEngineException.class)) {
WorkflowEngineException workflowEngineException = (WorkflowEngineException) rootCause;
if (Objects.equals(workflowEngineException.getCode(), "99806020")) {
log.info("AsyncApproveTaskJobHandler execute exception code: {} info: {}",
workflowEngineException.getCode(), rootCause.getMessage(), rootCause);
return true;
}
}
return false;
}