Feign本身支持Hystrix,不需要额外引入依赖,只需要有Feign的依赖就行了
熔断器的工作原理如下图所示:
1.开启Hystrix 修改yml文件
hystrix:
command:
default:
execution:
timeout:
enabled: true #开启熔断器
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 60000 #超时时间,毫秒
2.在微服务中调用方的client下创建接口实现类注解如下
@Component
3.修改调用方client接口上的注解
@FeignClient(value="tensquare‐base",fallback = LabelClientImpl.class)