Dear Team,
I am getting HystrixRuntimeException intermittently in my service when calling downstream service using spring rest template. Same downstream service is called from other services as well but not seeing any error. Not getting any timeout errors before short circuit.
DownStreamService:
execution:
isolation:
thread:
timeoutInMilliseconds: 3000
DownStreamServiceThreadPoolKey:
coreSize: 100
maximumSize: 100
maxQueueSize: 5
Code:
@HystrixCommand(commandKey = "DownStreamService", fallbackMethod = "downStreamApIResponse FallBackMethodForHystrixFailure", threadPoolKey = "DownStreamServiceThreadPoolKey")
public Observable<DownStreamApIResponse> getAPIResponse(HttpHeaders headers) {
return ResponseEntity< DownStreamApIResponse > responseEntity = restTemplate.exchange(
url, HttpMethod.GET, requestEntity, DownStreamApIResponse.class);
}
public DownStreamApIResponse downStreamApIResponse FallBackMethodForHystrixFailure(HttpHeaders headers,
Throwable hystrixCommandExp) throws TimeoutException {
if (hystrixCommandExp.getCause() instanceof HttpStatusCodeException) {
HttpStatusCodeException httpStatusCodeExp = (HttpStatusCodeException) hystrixCommandExp.getCause();
LOG.error("HttpStatusCodeException: " + httpStatusCodeExp.getMessage());
throw httpStatusCodeExp;
} else if (hystrixCommandExp instanceof HystrixTimeoutException) {
LOG.error("HystrixTimeoutException: " + hystrixCommandExp.getMessage());
throw new TimeoutException();
}
return new DownStreamApIResponse(status:"error");
}
Please let me know some ways to overcome this. Transactions per second of my API is more than 20 and 2 app instances running on cloud.
public DownStreamApIResponse downStreamApIResponse FallBackMethodForHystrixFailure(HttpHeaders headers,
Throwable hystrixCommandExp) throws TimeoutException {
if (hystrixCommandExp.getCause() instanceof HttpStatusCodeException) {
HttpStatusCodeException httpStatusCodeExp = (HttpStatusCodeException) hystrixCommandExp.getCause();
LOG.error": HttpStatusCodeException: " + httpStatusCodeExp.getMessage());
throw httpStatusCodeExp;
} else if (hystrixCommandExp instanceof HystrixTimeoutException) {
LOG.error(": HystrixTimeoutException: " + hystrixCommandExp.getMessage());
throw new TimeoutException();
}
throw new RuntimeException("Failure occurred while making rest call");
}
Error:
com.netflix.hystrix.exception.HystrixRuntimeException: DownStreamService short-circuited and fallback failed
java.lang.RuntimeException: Hystrix circuit short-circuited and is OPEN