xiewenjie пре 3 година
родитељ
комит
0af6846f40

+ 1 - 1
sxz-application/src/main/resources/application-prod.properties

@@ -39,7 +39,7 @@ spring.rabbitmq.password=guest
 # 开启重试
 spring.rabbitmq.listener.simple.retry.enabled=true
 # 重试次数,默认为3次
-spring.rabbitmq.listener.simple.retry.max-attempts=5
+spring.rabbitmq.listener.simple.retry.max-attempts=1
 ##mybatis-plus配置 ##
 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl
 mybatis-plus.configuration.map-underscore-to-camel-case=true

+ 0 - 12
sxz-base/src/main/java/com/fdkk/sxz/Interceptor/OkHttpLogInterceptor.java

@@ -11,13 +11,6 @@ import java.io.IOException;
 @Slf4j
 public class OkHttpLogInterceptor implements Interceptor {
 
-    public int maxRetry;//最大重试次数
-    private int retryNum = 0;//假如设置为3次重试的话,则最大可能请求4次(默认1次+3次重试)
-
-    public OkHttpLogInterceptor(int maxRetry) {
-        this.maxRetry = maxRetry;
-    }
-
 
     @NotNull
     @Override
@@ -31,11 +24,6 @@ public class OkHttpLogInterceptor implements Interceptor {
         long endTime = System.currentTimeMillis();
         long duration = endTime - startTime;
         OkHttpLogInterceptor.log.info("----------End-OkHttp:" + duration + "毫秒----------");
-        while (!response.isSuccessful() && retryNum < maxRetry) {
-            retryNum++;
-            OkHttpLogInterceptor.log.info("重试次数retryNum=" + retryNum);
-            response = chain.proceed(request);
-        }
         return response;
     }
 }

+ 9 - 5
sxz-base/src/main/java/com/fdkk/sxz/util/OkHttpUtils.java

@@ -29,11 +29,12 @@ public class OkHttpUtils {
     private static final String HTTP_FORM = "application/x-www-form-urlencoded; charset=utf-8";
 
 
-    private final static int READ_TIMEOUT = 30;
+    private final static int READ_TIMEOUT = 80;
 
-    private final static int CONNECT_TIMEOUT = 30;
+    private final static int CONNECT_TIMEOUT = 80;
 
-    private final static int WRITE_TIMEOUT = 30;
+    private final static int WRITE_TIMEOUT = 80;
+    private final static int PING_TIMEOUT = 80;
 
     private static volatile OkHttpClient okHttpClient;
 
@@ -46,9 +47,12 @@ public class OkHttpUtils {
         clientBuilder.connectTimeout(OkHttpUtils.CONNECT_TIMEOUT, TimeUnit.MINUTES);
         //写入超时
         clientBuilder.writeTimeout(OkHttpUtils.WRITE_TIMEOUT, TimeUnit.MINUTES);
+
+        clientBuilder.pingInterval(OkHttpUtils.PING_TIMEOUT, TimeUnit.MINUTES);
+
         //自定义连接池最大空闲连接数和等待时间大小,否则默认最大5个空闲连接
-        clientBuilder.connectionPool(new ConnectionPool(32, 30, TimeUnit.MINUTES));
-        clientBuilder.addInterceptor(new OkHttpLogInterceptor(3));
+        clientBuilder.connectionPool(new ConnectionPool(32, 70, TimeUnit.MINUTES));
+        clientBuilder.addInterceptor(new OkHttpLogInterceptor());
         OkHttpUtils.okHttpClient = clientBuilder.build();
     }
 

+ 1 - 9
sxz-core/src/main/java/com/fdkk/sxz/other/listener/RunBuild.java

@@ -20,7 +20,6 @@ import com.fdkk.sxz.other.mq.TopicRabbitConfig;
 import com.fdkk.sxz.util.*;
 import com.fdkk.sxz.webApi.service.*;
 import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
-import com.github.houbb.sisyphus.core.core.Retryer;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
 import org.springframework.amqp.rabbit.annotation.RabbitHandler;
@@ -33,7 +32,6 @@ import org.springframework.util.CollectionUtils;
 import java.io.File;
 import java.io.IOException;
 import java.util.*;
-import java.util.concurrent.Callable;
 
 /**
  * Created by Hb_zzZ on 2020/7/3.
@@ -842,13 +840,7 @@ public class RunBuild {
                 timer.start();
                 String maxUrl = maxObjUrl + "maxToDatasmith?uuid=" + fileId + "&max=" + maxName + "&flag=" + flag;
                 RunBuild.log.info("请求maxToDataSmith地址-{}", maxUrl);
-                Retryer.<String>newInstance()
-                        .callable(new Callable<String>() {
-                            @Override
-                            public String call() throws Exception {
-                                return OkHttpUtils.httpGet(maxUrl);
-                            }
-                        }).retryCall();
+                OkHttpUtils.httpGet(maxUrl);
                 RunBuild.log.info("运行maxToDataSmith结束-{}", fileId);
                 modelHandelStep.setUseTime(String.valueOf(timer.intervalMs()));
                 modelHandelStepService.updateById(modelHandelStep);