feat: 1.0.0

1. 优化代码
2. 修复客户端发生异常时,一直重试问题
This commit is contained in:
www.byteblogs.com 2023-04-19 22:46:51 +08:00 committed by byteblogs168
parent 90b802596e
commit 9260348e93
7 changed files with 32 additions and 21 deletions

View File

@ -60,7 +60,7 @@
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>4.0.60</version>
<version>4.0.66</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>

View File

@ -57,12 +57,12 @@
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-jdbc-template</artifactId>
<version>5.2.0</version>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
<version>5.2.0</version>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>

View File

@ -2,8 +2,8 @@ package com.aizuda.easy.retry.server.support.dispatch.actor.exec;
import akka.actor.AbstractActor;
import cn.hutool.core.util.IdUtil;
import com.x.retry.client.model.DispatchRetryDTO;
import com.x.retry.client.model.DispatchRetryResultDTO;
import com.aizuda.easy.retry.client.model.DispatchRetryDTO;
import com.aizuda.easy.retry.client.model.DispatchRetryResultDTO;
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.model.Result;

View File

@ -10,7 +10,7 @@ import org.springframework.util.CollectionUtils;
import java.util.*;
/**
* 重试构建
* 重试构建
*
* @author: www.byteblogs.com
* @date : 2021-11-29 18:42

View File

@ -6,6 +6,7 @@ import com.aizuda.easy.retry.server.support.FilterStrategy;
import com.aizuda.easy.retry.server.support.RetryContext;
import com.aizuda.easy.retry.server.support.StopStrategy;
import com.aizuda.easy.retry.server.support.WaitStrategy;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.concurrent.Callable;
@ -16,17 +17,18 @@ import java.util.concurrent.Callable;
* @author: www.byteblogs.com
* @date : 2021-11-29 18:57
*/
@Slf4j
public class RetryExecutor<V> {
private StopStrategy stopStrategy;
private WaitStrategy waitStrategy;
private List<FilterStrategy> filterStrategies;
private RetryContext<V> retryContext;
private final StopStrategy stopStrategy;
private final WaitStrategy waitStrategy;
private final List<FilterStrategy> filterStrategies;
private final RetryContext<V> retryContext;
public RetryExecutor(StopStrategy stopStrategy,
WaitStrategy waitStrategy,
List<FilterStrategy> filterStrategies,
RetryContext retryContext) {
RetryContext<V> retryContext) {
this.stopStrategy = stopStrategy;
this.waitStrategy = waitStrategy;
this.filterStrategies = filterStrategies;
@ -37,8 +39,6 @@ public class RetryExecutor<V> {
for (FilterStrategy filterStrategy : filterStrategies) {
if (!filterStrategy.filter(retryContext)) {
return false;
}
}
@ -55,8 +55,13 @@ public class RetryExecutor<V> {
*/
public V call(Callable<V> callable) throws Exception {
// 调用重试
V call = callable.call();
// 这里调用客户端可能会出现网络异常
V call = null;
try {
call = callable.call();
} catch (Exception e) {
log.error("客户端执行失败: [{}]", retryContext.getRetryTask());
}
retryContext.setCallResult(call);

View File

@ -1,6 +1,6 @@
package com.aizuda.easy.retry.server.support.strategy;
import com.x.retry.client.model.DispatchRetryResultDTO;
import com.aizuda.easy.retry.client.model.DispatchRetryResultDTO;
import com.aizuda.easy.retry.common.core.enums.RetryResultStatusEnum;
import com.aizuda.easy.retry.common.core.enums.StatusEnum;
import com.aizuda.easy.retry.common.core.model.Result;
@ -45,8 +45,13 @@ public class StopStrategies {
(MaxAttemptsPersistenceRetryContext<Result<DispatchRetryResultDTO>>) retryContext;
Result<DispatchRetryResultDTO> response = context.getCallResult();
if (Objects.isNull(response) || StatusEnum.YES.getStatus() != response.getStatus()) {
return Boolean.FALSE;
}
DispatchRetryResultDTO data = response.getData();
if (StatusEnum.YES.getStatus() != response.getStatus() || Objects.isNull(data)) {
if (Objects.isNull(data)) {
return Boolean.FALSE;
}

View File

@ -2,7 +2,7 @@ spring:
profiles:
active: dev
datasource:
name: x_retry
name: easy_retry
url: jdbc:mysql://localhost:3306/x_retry?useSSL=false&characterEncoding=utf8&useUnicode=true
username: root
password: root
@ -17,11 +17,12 @@ spring:
pool-name: x_retry
max-lifetime: 1800000
connection-test-query: SELECT 1
resources:
static-locations: classpath:admin/
web:
resources:
static-locations: classpath:admin/
mybatis-plus:
mapper-locations: classpath:/mapper/*.xml
typeAliasesPackage: com.x.retry.server.persistence.mybatis.po
typeAliasesPackage: com.aizuda.easy.retry.server.persistence.mybatis.po
global-config:
db-config:
field-strategy: NOT_EMPTY