我正在尝试访问在其他服务器上托管的给定服务。 我可以使用邮递员访问此服务。但是当我尝试在项目中访问此服务时,有时即使服务启动,我也会收到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;
}