feat(REQ-2924) - 记录重试失败后的异常信息
This commit is contained in:
parent
d05c42b606
commit
3c36040c29
@ -19,7 +19,7 @@ public enum FlowableEngineRespCode implements IModuleRespCode {
|
|||||||
ENGINE_USER_TASK_PARAM_ERROR("004", "构建后的查询审批人入参为空. 任务节点【nodeId:{}】, 该节点选择的\"审批人所在范围\"是:【{}】,请检查 cooperationOrg 参数"),
|
ENGINE_USER_TASK_PARAM_ERROR("004", "构建后的查询审批人入参为空. 任务节点【nodeId:{}】, 该节点选择的\"审批人所在范围\"是:【{}】,请检查 cooperationOrg 参数"),
|
||||||
ENGINE_NOTICE_CUSTOM_FLOW_ELEMENT_ERROR("005", "查询通知目标用户前参数发生异常,未获取到 WorkspaceType"),
|
ENGINE_NOTICE_CUSTOM_FLOW_ELEMENT_ERROR("005", "查询通知目标用户前参数发生异常,未获取到 WorkspaceType"),
|
||||||
ENGINE_ASYNC_COMMAND_EXECUTION_ERROR("006", "引擎出现 SQL 相关异常, 异常信息:【{}】"),
|
ENGINE_ASYNC_COMMAND_EXECUTION_ERROR("006", "引擎出现 SQL 相关异常, 异常信息:【{}】"),
|
||||||
ENGINE_ASYNC_COMMAND_EXECUTION_RETRY_GIVE_UP("007", "命令重试尝试【{}】次仍然失败,并出现异常, 将放弃"),
|
ENGINE_ASYNC_COMMAND_EXECUTION_RETRY_GIVE_UP("007", "命令重试尝试【{}】次仍然失败,并出现异常, 将放弃, 错误信息:{}"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import org.flowable.common.engine.impl.interceptor.Command;
|
|||||||
import org.flowable.common.engine.impl.interceptor.CommandConfig;
|
import org.flowable.common.engine.impl.interceptor.CommandConfig;
|
||||||
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
|
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static cn.axzo.workflow.core.common.code.FlowableEngineRespCode.ENGINE_ASYNC_COMMAND_EXECUTION_RETRY_GIVE_UP;
|
import static cn.axzo.workflow.core.common.code.FlowableEngineRespCode.ENGINE_ASYNC_COMMAND_EXECUTION_RETRY_GIVE_UP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,6 +31,7 @@ public class CustomRetryInterceptor extends AbstractCommandInterceptor {
|
|||||||
public <T> T execute(CommandConfig config, Command<T> command, CommandExecutor commandExecutor) {
|
public <T> T execute(CommandConfig config, Command<T> command, CommandExecutor commandExecutor) {
|
||||||
long waitTime = waitTimeInMs;
|
long waitTime = waitTimeInMs;
|
||||||
int failedAttempts = 0;
|
int failedAttempts = 0;
|
||||||
|
Throwable lastException = null;
|
||||||
do {
|
do {
|
||||||
if (failedAttempts > 0) {
|
if (failedAttempts > 0) {
|
||||||
log.warn("Waiting for {}ms before retrying the command.", waitTime);
|
log.warn("Waiting for {}ms before retrying the command.", waitTime);
|
||||||
@ -47,12 +50,13 @@ public class CustomRetryInterceptor extends AbstractCommandInterceptor {
|
|||||||
|
|
||||||
} catch (PersistenceException e) {
|
} catch (PersistenceException e) {
|
||||||
log.warn("Caught persistence exception: {}", e.getMessage(), e);
|
log.warn("Caught persistence exception: {}", e.getMessage(), e);
|
||||||
|
lastException = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
failedAttempts++;
|
failedAttempts++;
|
||||||
} while (failedAttempts <= numOfRetries);
|
} while (failedAttempts <= numOfRetries);
|
||||||
|
|
||||||
throw new WorkflowEngineException(ENGINE_ASYNC_COMMAND_EXECUTION_RETRY_GIVE_UP, String.valueOf(numOfRetries));
|
throw new WorkflowEngineException(ENGINE_ASYNC_COMMAND_EXECUTION_RETRY_GIVE_UP, String.valueOf(numOfRetries), lastException.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitBeforeRetry(long waitTime) {
|
protected void waitBeforeRetry(long waitTime) {
|
||||||
|
|||||||
@ -21,8 +21,10 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StopWatch;
|
import org.springframework.util.StopWatch;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
import org.springframework.web.context.request.ServletWebRequest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -135,6 +137,7 @@ public class ErrorReportAspect implements Ordered {
|
|||||||
if (workflowProperties.getFilterSendDingTalk().contains(operation.summary())) {
|
if (workflowProperties.getFilterSendDingTalk().contains(operation.summary())) {
|
||||||
filterSendDingTalk = false;
|
filterSendDingTalk = false;
|
||||||
}
|
}
|
||||||
|
ServletWebRequest request= (ServletWebRequest) RequestContextHolder.getRequestAttributes();
|
||||||
envConfig.type().executeAction(profile, operation.summary(), filterSendDingTalk, joinPoint.getArgs(), joinPoint.getSignature().toShortString(), e,
|
envConfig.type().executeAction(profile, operation.summary(), filterSendDingTalk, joinPoint.getArgs(), joinPoint.getSignature().toShortString(), e,
|
||||||
workflowProperties.getFilterOperations().contains(operation.summary()));
|
workflowProperties.getFilterOperations().contains(operation.summary()));
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user