Akka RetryFlow.withBackoff does not guarantee maxRetry attempt

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?

Hi Surendheran,

You hit issue #28425 that is fixed in the upcoming Akka 2.6.3 release which will be published today. (It is fixed in 2.6.2, but we do not recommend using that release for a different reson.)

Regards,
Enno.

Thank you :smiley: