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;
}