Akka http's withMaxConnections setting not working within RetryFlow.withBackoff

Hello,

I have a use-case to retry on certain http response using RetryFlow.withBackoff feature in akka streams. In addition I have applied withMaxConnections to 15 in Akka http’s connection pool and it does not work if I wrap http flow inside RetryFlow.withBackoff.

Example code:

        Http http = Http.get(actorSystem);
        ConnectHttp to = ConnectHttp.toHost(targetUri);

        ConnectionPoolSettings connectionPoolSettings = ConnectionPoolSettings.create(actorSystem)
                .withMaxConnections(15);

        Flow<Pair<HttpRequest, List<A>>, Pair<Try<HttpResponse>, List<A>>, ?> httpFlow 
          = httpFlow = http.cachedHostConnectionPool(to, connectionPoolSettings, actorSystem.log());
        
        return RetryFlow.withBackoff(Duration.ofSeconds(0),
                Duration.ofSeconds(1),
                0d,
                5,
                httpFlow,
                (httpRequestPair, responsePair) -> {
                    if (responsePair.first().isSuccess()) {
                        HttpResponse httpResponse = responsePair.first().get();
                        if (httpServerErrorPredicate.test(httpResponse.status().intValue())) {
                            httpResponse.entity().discardBytes(materializer);
                            return Optional.of(httpRequestPair);
                        }
                    }
                    return Optional.empty();
                }
        );

Seems like RetryFlow does not trigger asynchronous calls inside, is there any other option to fix this problem?

Hi Surendar,