定义一个不需要Hystrix支持的FeignClient
UserFeignClientWithoutHystrix.java
package com.example.demo.feign;
@FeignClient(name="spring-cloud-provider",fallback=UserFeignClientFallback.class,configuration=FeignClientWithoutHystrixConfig.class)
public interface UserFeignClientWithoutHystrix {
@RequestMapping(value="/user/get?id={id}",method=RequestMethod.GET)
public User get(@PathVariable("id") String id);
@RequestMapping(value="/user/list",method=RequestMethod.GET)
public List<User> list();
}
FeignClientWithoutHystrixConfig.java
package com.example.config;
@Configuration
public class FeignClientWithoutHystrixConfig {
/**
* 禁止某个api支持hystrix fallback
* @return
*/
@Bean
@Scope("prototype")
public Feign.Builder feignBuilder() {
return Feign.builder();
}
}
验证
当服务提供端启动的时候,UserFeignClientWithoutHystrix可以被正常调用。当服务提供端关闭之后UserFeignClientWithoutHystrix调用失败,但是不会调用Hystrix的回调(UserFeignClientFallback)