REQ-2924-新建job流程实例不存在,日志降级

This commit is contained in:
yangqicheng 2024-09-26 13:40:09 +08:00
parent 3da94cced2
commit 058562a5ae

View File

@ -1,12 +1,16 @@
package cn.axzo.workflow.core.engine.cmd; package cn.axzo.workflow.core.engine.cmd;
import cn.axzo.workflow.core.common.exception.WorkflowEngineException; import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
import org.apache.ibatis.exceptions.PersistenceException;
import org.flowable.common.engine.api.FlowableException; import org.flowable.common.engine.api.FlowableException;
import org.flowable.common.engine.api.FlowableOptimisticLockingException; import org.flowable.common.engine.api.FlowableOptimisticLockingException;
import org.flowable.common.engine.impl.interceptor.Command; import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext; import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import java.util.Arrays;
/** /**
* CommandContext 中的 WorkflowEngineException 进行日志降级 * CommandContext 中的 WorkflowEngineException 进行日志降级
@ -17,6 +21,8 @@ import org.slf4j.LoggerFactory;
public class CustomCommandContext extends CommandContext { public class CustomCommandContext extends CommandContext {
private static final Logger LOGGER = LoggerFactory.getLogger(CustomCommandContext.class); private static final Logger LOGGER = LoggerFactory.getLogger(CustomCommandContext.class);
private static final String[] PERSISTENCE_EXCEPTION_WARN_MESSAGE = new String[]{"act_ru_job"};
public CustomCommandContext(Command<?> command) { public CustomCommandContext(Command<?> command) {
super(command); super(command);
} }
@ -36,6 +42,10 @@ public class CustomCommandContext extends CommandContext {
LOGGER.info("Error while closing command context", exception); LOGGER.info("Error while closing command context", exception);
} else if (exception instanceof WorkflowEngineException) { } else if (exception instanceof WorkflowEngineException) {
LOGGER.warn("Workflow error while closing command context", exception); LOGGER.warn("Workflow error while closing command context", exception);
} else if (exception instanceof PersistenceException &&
StringUtils.hasText(exception.getMessage()) &&
Arrays.stream(PERSISTENCE_EXCEPTION_WARN_MESSAGE).anyMatch(m -> exception.getMessage().contains(m))) {
LOGGER.warn("persistence error while closing command context", exception);
} else { } else {
LOGGER.error("Error while closing command context", exception); LOGGER.error("Error while closing command context", exception);