I have a scenario to retry for some configured number whenever a stream ends with internal exception. To achieve this I tried RetryFlow.withBackoff functionality in Java. This triggers same source whenever decideRetry function returns other than Optional.empty(). But it’s retrying continuously even after the maxRetry threshold.
final Duration minBackoff = Duration.ofMillis(1000);
final Duration maxBackoff = Duration.ofMillis(1000);
final double randomFactor = 0d;
final int maxRetries = 2;
RetryFlow.withBackoff(
minBackoff,
maxBackoff,
randomFactor,
maxRetries,
flow,
(in, out) -> {
if(in.first() > 5 && in.second() > 0){
return Optional.of(Pair.create(in.first(), in.second()-1));
}
return Optional.empty();
});
Is there any workaround to control the retry flow on threshold limit?