Bläddra i källkod

远程调用配置优化

gaodm 4 år sedan
förälder
incheckning
0fad7cb5ef

+ 3 - 2
src/main/java/com/diagbot/client/CRFServiceClient.java

@@ -1,6 +1,7 @@
 package com.diagbot.client;
 
 
+import com.diagbot.client.hystrix.CRFServiceHystrix;
 import com.diagbot.vo.CRFVo;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -12,10 +13,10 @@ import org.springframework.web.bind.annotation.RequestBody;
  * @author: Mark Huang
  * @time: 2019/12/13 9:52
  */
-@FeignClient(value = "CRF-service", url="${CRF.url}")
+@FeignClient(value = "CRF-service", url="${CRF.url}", fallback = CRFServiceHystrix.class)
 public interface CRFServiceClient {
 
-    @PostMapping(value = "")
+    @PostMapping(value = "/api/mr_info_ex/entity_predict")
     String getAnnotation(@RequestBody CRFVo crfVo);
 }
 

+ 11 - 4
src/main/java/com/diagbot/client/hystrix/CRFServiceHystrix.java

@@ -1,10 +1,17 @@
 package com.diagbot.client.hystrix;
 
-
+import com.diagbot.client.CRFServiceClient;
+import com.diagbot.vo.CRFVo;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
-
+import org.springframework.web.bind.annotation.RequestBody;
 
 @Component
-public class CRFServiceHystrix {
-
+@Slf4j
+public class CRFServiceHystrix implements CRFServiceClient {
+    @Override
+    public String getAnnotation(@RequestBody CRFVo crfVo) {
+        log.error("【hystrix】调用{}异常", "CRF-getAnnotation");
+        return null;
+    }
 }

+ 1 - 1
src/main/resources/application-dev.yml

@@ -127,4 +127,4 @@ swagger:
   enable: true
 
 CRF:
-  url: http://192.168.2.234:3456/api/mr_info_ex/entity_predict
+  url: http://192.168.2.234:3456

+ 1 - 1
src/main/resources/application-local.yml

@@ -127,4 +127,4 @@ swagger:
   enable: true
 
 CRF:
-  url: http://192.168.2.234:3456/api/mr_info_ex/entity_predict
+  url: http://192.168.2.234:3456

+ 1 - 1
src/main/resources/application-pre.yml

@@ -128,4 +128,4 @@ swagger:
   enable: true
 
 CRF:
-  url: http://192.168.2.234:3456/api/mr_info_ex/entity_predict
+  url: http://192.168.2.234:3456

+ 1 - 1
src/main/resources/application-pro.yml

@@ -129,4 +129,4 @@ swagger:
   enable: true
 
 CRF:
-  url: http://192.168.2.234:3456/api/mr_info_ex/entity_predict
+  url: http://192.168.2.234:3456

+ 1 - 1
src/main/resources/application-test.yml

@@ -128,4 +128,4 @@ swagger:
   enable: true
 
 CRF:
-  url: http://192.168.2.234:3456/api/mr_info_ex/entity_predict
+  url: http://192.168.2.234:3456