Saurabh
Saurabh

Reputation: 73609

How to have multiple http configurations with akka-http

With akka-http, you can provide typesafe config as described here which is put in application.conf. so a minified config can look like following:

akka.http {
  client {
    connecting-timeout = 10s
  }
  host-connection-pool {
    max-connections = 4
    max-open-requests = 32
  }
}

My question is if I have to call different external services in the app, I create different pool to those. How do I change these config(max-connections, max-open-requests) for these different pools calling different external services.

Upvotes: 0

Views: 560

Answers (1)

Saurabh
Saurabh

Reputation: 73609

One solution I have found so far for this is, overwriting the connectionPoolSettings and passing it when creating http pool:

Http().superPool[RequestTracker](
      settings = ConnectionPoolSettings(httpActorSystem).withMaxOpenRequests(1).withMaxConnections(1)
    )(httpMat)

Here I can provide appropriate config for maxOpenRequests and maxConnectionsas par my requirement.

Upvotes: 1

Related Questions