0

I am trying to access a given service that is hosted on a different server. I can access this service using postman. but when I am trying to access this service within my project then sometimes I get CircuitBreakerOpenException even when service is up. here is my code

    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;
    }
nand
  • 517
  • 2
  • 13
  • 29
  • Please read "How to create a [mcve]". Then use the [edit] link to improve your question (do not add more information via comments). Otherwise we are not able to answer your question and help you. – GhostCat Oct 08 '18 at 18:01
  • Such as: the exception stack trace, pointing to the line that throws. – GhostCat Oct 08 '18 at 18:01

0 Answers0