提交 633e5fcb 编写于 作者: W wangfeihu

fallback方法混乱的问题解决

使用PaymentHystrixService的实现类
在PaymentHystrixService接口的@FeignClient注解的fallback属性值是它的降级实现类PaymentFallbackService.class
上级 e4686af3
package com.afeiamic.springcloud.service;
import com.afeiamic.springcloud.service.fallback.PaymentFallbackService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@Component
@FeignClient(value = "CLOUD-PROVIDER-HYSTRIX-PAYMENT")
@FeignClient(value = "CLOUD-PROVIDER-HYSTRIX-PAYMENT", fallback = PaymentFallbackService.class)
public interface PaymentHystrixService {
@GetMapping("/payment/hystrix/ok/{id}")
......
package com.afeiamic.springcloud.service.fallback;
import com.afeiamic.springcloud.service.PaymentHystrixService;
import org.springframework.stereotype.Component;
@Component
public class PaymentFallbackService implements PaymentHystrixService {
@Override
public String paymentInfo_OK(Integer id) {
return "PaymentFallbackService fallback paymentInfo_OK, w(゚Д゚)w";
}
@Override
public String paymentInfo_Timeout(Integer id) {
return "PaymentFallbackService fallback paymentInfo_Timeout, w(゚Д゚)w";
}
}
......@@ -6,7 +6,12 @@ eureka:
register-with-eureka: false
service-url:
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/
# logging:
# level:
# # feign日志以什么级别监控哪个接口
# com.afeiamic.springcloud.service: debug
# 用于服务降级 在注解@FeignClient中添加fallback属性值
feign:
hystrix:
enabled: true
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册