I am using resilience4j.retry with resilience4j.circuitbreaker. Service1
is calling another service Service2
, which can throw exceptions. Even if I get exceptions, I should try to connect for at least defined no of times waitDuration * maxRetryAttempts
.
Service1 ---> calling ---> Service2
application.yml
resilience4j.retry:
instances:
service1:
maxRetryAttempts: 4
waitDuration: 1000 #ms
retryExceptions:
- org.apache.http.conn.HttpHostConnectException
- org.apache.thrift.TException
- java.net.ConnectException
Service1Repository.java
Service2Response response = CircuitBreaker.decorateSupplier(circuitBreaker,
Retry.decorateSupplier(retry, () -> {
try {
return service2.getdata(params);
} catch (TException e) {
log.error("msg", e);
throw new Service1Exception("msg", e);
}
})
).get();
However, when Service2
is down, it is not retrying (max 4 times, each after 1000ms should happen) I am getting a response (null
in my case) immediately. I tried with increasing values (10000ms), still the same. I am seeing logs are printed but service should wait for waitDuration * maxRetryAttempts
if Serviece2
is down.