Теперь я использую симуляцию с hystrix, оказывается, что Circuit перейдет в состояние Open, когда метод отката вызывается 20 раз за 5 секунд. Как я могу изменить это правило. Например, позвольте статусу цепи измениться на открытие, когда метод отката вызывается 50 раз за 5 с, или по скорости обратного вызова. Вот мой основной код 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;
}
}
}