Selaa lähdekoodia

解决算法调用超时问题,配置文件新增feign超时时间配置。

jessie 5 vuotta sitten
vanhempi
commit
33ef6ec650

+ 13 - 0
src/main/java/com/pavis/ai/app/crocr/common/config/WebMvcConfig.java

@@ -2,7 +2,10 @@ package com.pavis.ai.app.crocr.common.config;
 
 import com.pavis.ai.app.crocr.common.config.properties.CommonProperties;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.web.context.request.async.TimeoutCallableProcessingInterceptor;
+import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
@@ -20,5 +23,15 @@ public class WebMvcConfig implements WebMvcConfigurer {
 
     }
 
+    @Override
+    public void configureAsyncSupport(final AsyncSupportConfigurer configurer) {
+        configurer.setDefaultTimeout(600000);
+        configurer.registerCallableInterceptors(timeoutInterceptor());
+    }
+    @Bean
+    public TimeoutCallableProcessingInterceptor timeoutInterceptor() {
+        return new TimeoutCallableProcessingInterceptor();
+    }
+
 
 }

+ 4 - 1
src/main/java/com/pavis/ai/app/crocr/service/InternalSendService.java

@@ -13,7 +13,10 @@ import java.util.Map;
  * @desc 内部算法调用。
  **/
 // 测试
-@FeignClient(value = "internalSendService",url = "http://192.168.1.60:9955")
+// @FeignClient(value = "internalSendService",url = "http://192.168.1.60:9955")
+// @FeignClient(value = "internalSendService",url = "http://192.168.1.202:9955")
+// @FeignClient(value = "cr-ocr-server",url = "http://192.168.1.202:9955")
+@FeignClient(value = "cr-ocr-server",url = "http://192.168.1.202:9955")
 // 线上
 // @FeignClient(value = "internalSendService",url = "http://alg:9955")
 public interface InternalSendService {

+ 8 - 0
src/main/resources/application.yml

@@ -1,6 +1,14 @@
 server:
 #  port: 10084
   port: 80
+feign:
+#  hystrix:
+#    enabled: false
+  client:
+    config:
+      default:
+        connect-timeout: 600000
+        read-timeout: 600000
 spring:
   application:
     name: cr-ocr-server