feat: 1.1.0
1. 优化变量名称和bizId的注解注释
This commit is contained in:
parent
2fe0753ce4
commit
77eb148ec0
@ -50,7 +50,7 @@ public @interface Retryable {
|
||||
|
||||
/**
|
||||
* 业务id生成器
|
||||
* 同一个组的同一个场景下只会存在一个相同的bizId重试任务, 若存在相同的则上报服务后会被幂等处理
|
||||
* 同一个组的同一个场景下只会存在一个相同的bizId并且状态为'重试中'的任务, 若存在相同的则上报服务后会被幂等处理
|
||||
* 比如:
|
||||
* 组: AGroup
|
||||
* 场景: BScene
|
||||
|
@ -101,7 +101,7 @@ public class NettyHttpConnectClient implements Lifecycle, ApplicationContextAwar
|
||||
FullHttpRequest request = new DefaultFullHttpRequest(
|
||||
HttpVersion.HTTP_1_0, method, url, Unpooled.wrappedBuffer(body.getBytes(StandardCharsets.UTF_8)));
|
||||
|
||||
ServerProperties serverProperties = SpringContext.applicationContext.getBean(ServerProperties.class);
|
||||
ServerProperties serverProperties = SpringContext.CONTEXT.getBean(ServerProperties.class);
|
||||
|
||||
request.headers()
|
||||
.set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON)
|
||||
|
@ -43,7 +43,7 @@ public class EasyRetryProperties {
|
||||
}
|
||||
|
||||
public static String getGroup() {
|
||||
EasyRetryProperties properties = SpringContext.applicationContext.getBean(EasyRetryProperties.class);
|
||||
EasyRetryProperties properties = SpringContext.CONTEXT.getBean(EasyRetryProperties.class);
|
||||
return Objects.requireNonNull(properties).group;
|
||||
}
|
||||
}
|
||||
|
@ -17,21 +17,21 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
public class SpringContext implements ApplicationContextAware {
|
||||
|
||||
public static ApplicationContext applicationContext;
|
||||
public static ApplicationContext CONTEXT;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
SpringContext.applicationContext = applicationContext;
|
||||
SpringContext.CONTEXT = applicationContext;
|
||||
}
|
||||
|
||||
public static <T> T getBeanByType(Class<T> clazz) {
|
||||
return applicationContext.getBean(clazz);
|
||||
return CONTEXT.getBean(clazz);
|
||||
}
|
||||
|
||||
|
||||
public static synchronized <T> T getBean(String name) {
|
||||
try {
|
||||
return (T) applicationContext.getBean(name);
|
||||
return (T) CONTEXT.getBean(name);
|
||||
} catch (BeansException var2) {
|
||||
log.error(" BeanName:{} not exist,Exception => {}", name, var2.getMessage());
|
||||
return null;
|
||||
@ -40,7 +40,7 @@ public class SpringContext implements ApplicationContextAware {
|
||||
|
||||
public static synchronized <T> T getBean(String name, Class<T> requiredType) {
|
||||
try {
|
||||
return applicationContext.getBean(name, requiredType);
|
||||
return CONTEXT.getBean(name, requiredType);
|
||||
} catch (BeansException | NullPointerException var3) {
|
||||
log.error(" BeanName:{} not exist,Exception => {}", name, var3.getMessage());
|
||||
return null;
|
||||
|
@ -68,7 +68,7 @@ public class LogUtils {
|
||||
private static Boolean getLogStatus() {
|
||||
|
||||
try {
|
||||
Environment environment = SpringContext.applicationContext.getBean(Environment.class);
|
||||
Environment environment = SpringContext.CONTEXT.getBean(Environment.class);
|
||||
return environment.getProperty("x.retry.log.status", Boolean.class, Boolean.TRUE);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import org.springframework.core.env.Environment;
|
||||
*/
|
||||
public class EnvironmentUtils {
|
||||
|
||||
private static final Environment environment = SpringContext.applicationContext.getBean(Environment.class);
|
||||
private static final Environment environment = SpringContext.CONTEXT.getBean(Environment.class);
|
||||
public static final String DEFAULT_ENV = "default ";
|
||||
|
||||
/**
|
||||
@ -21,7 +21,7 @@ public class EnvironmentUtils {
|
||||
*/
|
||||
private static Boolean getLogStatus() {
|
||||
|
||||
Environment environment = SpringContext.applicationContext.getBean(Environment.class);
|
||||
Environment environment = SpringContext.CONTEXT.getBean(Environment.class);
|
||||
return environment.getProperty("flaky.retry.log.status", Boolean.class, Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class NettyHttpServerHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
registerHandler.syncVersion(clientVersion, groupName, hostIp, hostPort, contextPath);
|
||||
|
||||
UrlBuilder builder = UrlBuilder.ofHttp(uri);
|
||||
Collection<HttpRequestHandler> httpRequestHandlers = SpringContext.applicationContext.getBeansOfType(HttpRequestHandler.class).values();
|
||||
Collection<HttpRequestHandler> httpRequestHandlers = SpringContext.CONTEXT.getBeansOfType(HttpRequestHandler.class).values();
|
||||
for (HttpRequestHandler httpRequestHandler : httpRequestHandlers) {
|
||||
if (httpRequestHandler.supports(builder.getPathStr()) && method.name().equals(httpRequestHandler.method().name())) {
|
||||
return httpRequestHandler.doHandler(content, builder, headers);
|
||||
|
@ -160,7 +160,7 @@ public class WaitStrategies {
|
||||
public LocalDateTime computeRetryTime(RetryContext retryContext) {
|
||||
MaxAttemptsPersistenceRetryContext context = (MaxAttemptsPersistenceRetryContext) retryContext;
|
||||
RetryTask retryTask = context.getRetryTask();
|
||||
ConfigAccess configAccess = SpringContext.applicationContext.getBean("configAccessProcessor", ConfigAccess.class);
|
||||
ConfigAccess configAccess = SpringContext.CONTEXT.getBean("configAccessProcessor", ConfigAccess.class);
|
||||
|
||||
SceneConfig sceneConfig =
|
||||
configAccess.getSceneConfigByGroupNameAndSceneName(retryTask.getGroupName(), retryTask.getSceneName());
|
||||
@ -178,7 +178,7 @@ public class WaitStrategies {
|
||||
MaxAttemptsPersistenceRetryContext context = (MaxAttemptsPersistenceRetryContext) retryContext;
|
||||
RetryTask retryTask = context.getRetryTask();
|
||||
|
||||
ConfigAccess configAccess = SpringContext.applicationContext.getBean(ConfigAccess.class);
|
||||
ConfigAccess configAccess = SpringContext.CONTEXT.getBean(ConfigAccess.class);
|
||||
|
||||
SceneConfig sceneConfig =
|
||||
configAccess.getSceneConfigByGroupNameAndSceneName(retryTask.getGroupName(), retryTask.getSceneName());
|
||||
@ -222,7 +222,7 @@ public class WaitStrategies {
|
||||
if (Objects.nonNull(retryContext)) {
|
||||
RetryTask retryTask = retryContext.getRetryTask();
|
||||
|
||||
ConfigAccess configAccess = SpringContext.applicationContext.getBean(ConfigAccess.class);
|
||||
ConfigAccess configAccess = SpringContext.CONTEXT.getBean(ConfigAccess.class);
|
||||
SceneConfig sceneConfig =
|
||||
configAccess.getSceneConfigByGroupNameAndSceneName(retryTask.getGroupName(), retryTask.getSceneName());
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class TestExistsTransactionalRetryService {
|
||||
}
|
||||
|
||||
TransactionalEvent<String> event = new TransactionalEvent<>("123");
|
||||
SpringContext.applicationContext.publishEvent(event);
|
||||
SpringContext.CONTEXT.publishEvent(event);
|
||||
|
||||
return "testSimpleInsert"+school.getAddress();
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import com.example.mapper.SchoolMapper;
|
||||
import com.example.mapper.StudentMapper;
|
||||
import com.example.model.TransactionalEvent;
|
||||
import com.example.po.School;
|
||||
import com.example.po.Student;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -51,7 +50,7 @@ public class TestExistsTransactionalRetryService2 {
|
||||
}
|
||||
|
||||
TransactionalEvent<String> event = new TransactionalEvent<>("123");
|
||||
SpringContext.applicationContext.publishEvent(event);
|
||||
SpringContext.CONTEXT.publishEvent(event);
|
||||
|
||||
return "testSimpleInsert"+school.getAddress();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user