feat:3.0.0
升级spring boot 3.1.3
This commit is contained in:
parent
8bfa7b1251
commit
baa122cb56
@ -8,12 +8,15 @@ import com.aizuda.easy.retry.client.core.cache.RetryerInfoCache;
|
|||||||
import com.aizuda.easy.retry.client.core.callback.RetryCompleteCallback;
|
import com.aizuda.easy.retry.client.core.callback.RetryCompleteCallback;
|
||||||
import com.aizuda.easy.retry.client.core.exception.EasyRetryClientException;
|
import com.aizuda.easy.retry.client.core.exception.EasyRetryClientException;
|
||||||
import com.aizuda.easy.retry.client.core.intercepter.RetrySiteSnapshot;
|
import com.aizuda.easy.retry.client.core.intercepter.RetrySiteSnapshot;
|
||||||
|
import com.aizuda.easy.retry.client.core.loader.EasyRetrySpiLoader;
|
||||||
import com.aizuda.easy.retry.client.core.retryer.RetryerInfo;
|
import com.aizuda.easy.retry.client.core.retryer.RetryerInfo;
|
||||||
import com.aizuda.easy.retry.client.core.retryer.RetryerResultContext;
|
import com.aizuda.easy.retry.client.core.retryer.RetryerResultContext;
|
||||||
import com.aizuda.easy.retry.client.core.loader.EasyRetrySpiLoader;
|
|
||||||
import com.aizuda.easy.retry.client.core.serializer.JacksonSerializer;
|
import com.aizuda.easy.retry.client.core.serializer.JacksonSerializer;
|
||||||
import com.aizuda.easy.retry.client.core.strategy.RetryStrategy;
|
import com.aizuda.easy.retry.client.core.strategy.RetryStrategy;
|
||||||
|
import com.aizuda.easy.retry.client.model.DispatchRetryDTO;
|
||||||
|
import com.aizuda.easy.retry.client.model.DispatchRetryResultDTO;
|
||||||
import com.aizuda.easy.retry.client.model.GenerateRetryIdempotentIdDTO;
|
import com.aizuda.easy.retry.client.model.GenerateRetryIdempotentIdDTO;
|
||||||
|
import com.aizuda.easy.retry.client.model.RetryCallbackDTO;
|
||||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||||
import com.aizuda.easy.retry.common.core.enums.RetryResultStatusEnum;
|
import com.aizuda.easy.retry.common.core.enums.RetryResultStatusEnum;
|
||||||
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
||||||
@ -23,10 +26,6 @@ import com.aizuda.easy.retry.common.core.model.Result;
|
|||||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||||
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
|
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.aizuda.easy.retry.client.model.DispatchRetryDTO;
|
|
||||||
import com.aizuda.easy.retry.client.model.DispatchRetryResultDTO;
|
|
||||||
import com.aizuda.easy.retry.client.model.RetryCallbackDTO;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -37,8 +36,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -82,10 +79,7 @@ public class RetryEndPoint {
|
|||||||
DispatchRetryResultDTO executeRespDto = new DispatchRetryResultDTO();
|
DispatchRetryResultDTO executeRespDto = new DispatchRetryResultDTO();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
RetrySiteSnapshot.setAttemptNumber(executeReqDto.getRetryCount());
|
||||||
// TODO 此处用ThreadLocal替换
|
|
||||||
HttpServletRequest request = Objects.requireNonNull(attributes).getRequest();
|
|
||||||
request.setAttribute("attemptNumber", executeReqDto.getRetryCount());
|
|
||||||
|
|
||||||
RetryerResultContext retryerResultContext = retryStrategy.openRetry(executeReqDto.getScene(),
|
RetryerResultContext retryerResultContext = retryStrategy.openRetry(executeReqDto.getScene(),
|
||||||
executeReqDto.getExecutorName(), deSerialize);
|
executeReqDto.getExecutorName(), deSerialize);
|
||||||
@ -106,7 +100,6 @@ public class RetryEndPoint {
|
|||||||
executeRespDto.setResultJson(JsonUtil.toJsonString(retryerResultContext.getResult()));
|
executeRespDto.setResultJson(JsonUtil.toJsonString(retryerResultContext.getResult()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
RetrySiteSnapshot.removeAll();
|
RetrySiteSnapshot.removeAll();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
|||||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||||
import com.aizuda.easy.retry.common.core.model.EasyRetryHeaders;
|
import com.aizuda.easy.retry.common.core.model.EasyRetryHeaders;
|
||||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
@ -13,7 +14,6 @@ import org.springframework.stereotype.Component;
|
|||||||
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 javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +48,19 @@ public class RetrySiteSnapshot {
|
|||||||
* 进入方法入口时间标记
|
* 进入方法入口时间标记
|
||||||
*/
|
*/
|
||||||
private static final RetrySiteSnapshotContext<Long> ENTRY_METHOD_TIME = EasyRetrySpiLoader.loadRetrySiteSnapshotContext();
|
private static final RetrySiteSnapshotContext<Long> ENTRY_METHOD_TIME = EasyRetrySpiLoader.loadRetrySiteSnapshotContext();
|
||||||
|
private static final RetrySiteSnapshotContext<Integer> ATTEMPT_NUMBER = EasyRetrySpiLoader.loadRetrySiteSnapshotContext();
|
||||||
|
|
||||||
|
public static Integer getAttemptNumber() {
|
||||||
|
return ATTEMPT_NUMBER.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAttemptNumber(Integer attemptNumber) {
|
||||||
|
ATTEMPT_NUMBER.set(attemptNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeAttemptNumber() {
|
||||||
|
ATTEMPT_NUMBER.remove();
|
||||||
|
}
|
||||||
|
|
||||||
public static Integer getStage() {
|
public static Integer getStage() {
|
||||||
return RETRY_STAGE.get();
|
return RETRY_STAGE.get();
|
||||||
@ -156,7 +169,7 @@ public class RetrySiteSnapshot {
|
|||||||
removeStatus();
|
removeStatus();
|
||||||
removeMethodEntrance();
|
removeMethodEntrance();
|
||||||
removeStage();
|
removeStage();
|
||||||
|
removeAttemptNumber();
|
||||||
removeEntryMethodTime();
|
removeEntryMethodTime();
|
||||||
removeRetryHeader();
|
removeRetryHeader();
|
||||||
removeRetryStatusCode();
|
removeRetryStatusCode();
|
||||||
|
@ -3,22 +3,17 @@ package com.aizuda.easy.retry.client.core.strategy;
|
|||||||
import com.aizuda.easy.retry.client.core.RetryExecutor;
|
import com.aizuda.easy.retry.client.core.RetryExecutor;
|
||||||
import com.aizuda.easy.retry.client.core.RetryExecutorParameter;
|
import com.aizuda.easy.retry.client.core.RetryExecutorParameter;
|
||||||
import com.aizuda.easy.retry.client.core.intercepter.RetrySiteSnapshot;
|
import com.aizuda.easy.retry.client.core.intercepter.RetrySiteSnapshot;
|
||||||
import com.github.rholder.retry.*;
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.aizuda.easy.retry.client.core.retryer.RetryType;
|
import com.aizuda.easy.retry.client.core.retryer.RetryType;
|
||||||
import com.aizuda.easy.retry.client.core.retryer.RetryerInfo;
|
import com.aizuda.easy.retry.client.core.retryer.RetryerInfo;
|
||||||
import com.aizuda.easy.retry.client.core.retryer.RetryerResultContext;
|
import com.aizuda.easy.retry.client.core.retryer.RetryerResultContext;
|
||||||
import com.aizuda.easy.retry.common.core.enums.RetryResultStatusEnum;
|
import com.aizuda.easy.retry.common.core.enums.RetryResultStatusEnum;
|
||||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||||
|
import com.github.rholder.retry.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -108,9 +103,7 @@ public class RemoteRetryStrategies extends AbstractRetryStrategies {
|
|||||||
return Collections.singletonList(new RetryListener() {
|
return Collections.singletonList(new RetryListener() {
|
||||||
@Override
|
@Override
|
||||||
public <V> void onRetry(Attempt<V> attempt) {
|
public <V> void onRetry(Attempt<V> attempt) {
|
||||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
Integer attemptNumber = RetrySiteSnapshot.getAttemptNumber();
|
||||||
HttpServletRequest request = Objects.requireNonNull(attributes).getRequest();
|
|
||||||
Integer attemptNumber = (Integer) request.getAttribute("attemptNumber");
|
|
||||||
if (attempt.hasResult()) {
|
if (attempt.hasResult()) {
|
||||||
LogUtils.info(log, "easy-retry 远程重试成功,第[{}]次调度", attemptNumber);
|
LogUtils.info(log, "easy-retry 远程重试成功,第[{}]次调度", attemptNumber);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
com.aizuda.easy.retry.client.starter.EasyRetryClientAutoConfiguration
|
@ -0,0 +1 @@
|
|||||||
|
com.aizuda.easy.retry.common.core.CommonCoreConfigure
|
@ -1,5 +1,7 @@
|
|||||||
package com.aizuda.easy.retry.template.datasource.config;
|
package com.aizuda.easy.retry.template.datasource.config;
|
||||||
|
|
||||||
|
import com.aizuda.easy.retry.template.datasource.access.Access;
|
||||||
|
import com.aizuda.easy.retry.template.datasource.access.AccessTemplate;
|
||||||
import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
|
import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
|
||||||
import com.aizuda.easy.retry.template.datasource.utils.RequestDataHelper;
|
import com.aizuda.easy.retry.template.datasource.utils.RequestDataHelper;
|
||||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
|
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
|
||||||
@ -27,7 +29,7 @@ import java.util.List;
|
|||||||
* @date : 2023-08-04 12:37
|
* @date : 2023-08-04 12:37
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan("com.aizuda.easy.retry.template.datasource.*")
|
@ComponentScan("com.aizuda.easy.retry.template.datasource.**")
|
||||||
@MapperScan(value = "com.aizuda.easy.retry.template.datasource.persistence.mapper", sqlSessionTemplateRef = "sqlSessionTemplate")
|
@MapperScan(value = "com.aizuda.easy.retry.template.datasource.persistence.mapper", sqlSessionTemplateRef = "sqlSessionTemplate")
|
||||||
public class EasyRetryTemplateAutoConfiguration {
|
public class EasyRetryTemplateAutoConfiguration {
|
||||||
@Bean("sqlSessionFactory")
|
@Bean("sqlSessionFactory")
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.aizuda.easy.retry.template.datasource.config.EasyRetryTemplateAutoConfiguration
|
|
@ -0,0 +1 @@
|
|||||||
|
com.aizuda.easy.retry.template.datasource.config.EasyRetryTemplateAutoConfiguration
|
@ -1,2 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.aizuda.easy.retry.mariadb.datasource.config.EasyRetryMariadbAutoConfiguration
|
|
@ -0,0 +1 @@
|
|||||||
|
com.aizuda.easy.retry.mariadb.datasource.config.EasyRetryMariadbAutoConfiguration
|
@ -1,2 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.aizuda.easy.retry.mysql.datasource.config.EasyRetryMysqlAutoConfiguration
|
|
@ -0,0 +1 @@
|
|||||||
|
com.aizuda.easy.retry.mysql.datasource.config.EasyRetryMysqlAutoConfiguration
|
@ -1,2 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.aizuda.easy.retry.postgres.datasource.config.EasyRetryPostgresAutoConfiguration
|
|
@ -0,0 +1 @@
|
|||||||
|
com.aizuda.easy.retry.postgres.datasource.config.EasyRetryPostgresAutoConfiguration
|
@ -9,10 +9,10 @@ import com.aizuda.easy.retry.server.web.annotation.LoginUser;
|
|||||||
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
|
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
|
||||||
import com.aizuda.easy.retry.server.web.annotation.RoleEnum;
|
import com.aizuda.easy.retry.server.web.annotation.RoleEnum;
|
||||||
import com.aizuda.easy.retry.server.web.model.response.SystemUserResponseVO;
|
import com.aizuda.easy.retry.server.web.model.response.SystemUserResponseVO;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,14 +12,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||||
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
|
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
|
||||||
import com.aizuda.easy.retry.server.web.annotation.RoleEnum;
|
import com.aizuda.easy.retry.server.web.annotation.RoleEnum;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.aizuda.easy.retry.server.web.interceptor;
|
package com.aizuda.easy.retry.server.web.interceptor;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:byteblogs
|
* @Author:byteblogs
|
||||||
* @Date:2018/09/27 12:52
|
* @Date:2018/09/27 12:52
|
||||||
|
6
pom.xml
6
pom.xml
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<revision>2.3.0-SNAPSHOT</revision>
|
<revision>3.0.0-SNAPSHOT</revision>
|
||||||
<dingding-talk.version>1.0.0</dingding-talk.version>
|
<dingding-talk.version>1.0.0</dingding-talk.version>
|
||||||
<netty-all.version>4.1.94.Final</netty-all.version>
|
<netty-all.version>4.1.94.Final</netty-all.version>
|
||||||
<hutool-all.version>5.8.19</hutool-all.version>
|
<hutool-all.version>5.8.19</hutool-all.version>
|
||||||
|
Loading…
Reference in New Issue
Block a user