现在我在 hystrix 中使用 feign,结果发现,当 fallback 方法在 5s 内调用 20 次时,Circuit 将变为 Open 状态。我怎样才能改变这个规则。例如,当fallback方法在5s内调用50次时,让Circuit状态变为open,或者通过fallback回调率。这是我的主要java代码。
ConsumerApplication.java
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableCircuitBreaker
@RibbonClients({@RibbonClient(name = "cloud-provider", configuration = CloudProviderConfiguration.class)})
public class ConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
}
}
UserFeignClient.java
@FeignClient(name = "cloud-provider", fallback = UserFeignClient.HystrixClientFallback.class)
public interface UserFeignClient {
@RequestMapping("/{id}")
BaseResponse findByIdFeign(@RequestParam("id") Long id);
@RequestMapping("/add")
BaseResponse addUserFeign(UserVo userVo);
@Component
class HystrixClientFallback implements UserFeignClient {
private static final Logger LOGGER = LoggerFactory.getLogger(HystrixClientFallback.class);
@Override
public BaseResponse findByIdFeign(@RequestParam("id") Long id) {
BaseResponse response = new BaseResponse();
response.setMessage("disable!!!!");
return response;
}
@Override
public BaseResponse addUserFeign(UserVo userVo) {
BaseResponse response = new BaseResponse();
response.setMessage("disable");
return response;
}
}
}