CircuitBreakerOpenException, даже когда служба работает - PullRequest
0 голосов
/ 08 октября 2018

Я пытаюсь получить доступ к определенной службе, размещенной на другом сервере.Я могу получить доступ к этой услуге с помощью почтальона.но когда я пытаюсь получить доступ к этому сервису в моем проекте, иногда я получаю исключение CircuitBreakerOpenException, даже когда сервис работает.вот мой код

    private CircuitBreaker breaker = new CircuitBreaker().withFailureThreshold(getFailuresNumber()).withSuccessThreshold(getSuccessThreshold()).withDelay(getDelay(), TimeUnit.SECONDS)
        .withTimeout(getTimeOut(), TimeUnit.SECONDS);

   @Resource(name = "cityRestService")
    private CityRestService cityRestService;

    @Override
    public CustomData getHotelInGIvenCity(final String cityId) {
        CustomData result = null;
        if (!StringUtils.isBlank(cityId)) {
            try {
                logger.info("getHotelInGIvenCity >> cityId >> " + cityId + " breaker state " + breaker.getState() + " brkaer >> " + breaker.getTimeout());
                result = buildCity(Failsafe.with(breaker).get(new ContextualCallable<city>() {
                    public List<city> call(ExecutionContext context) throws Exception {
                        List<city> cities = cityRestService.list(null);

                        return cities;
                    }
                }));
            }
            catch (Exception e) {
                logger.info("Could not retrieve city", cityId, e);
            }
        }
        logger.debug("Breaker state is " + breaker.getState());
        return result;
    }
...