【问题标题】:How to have multiple http configurations with akka-http如何使用 akka-http 进行多个 http 配置
【发布时间】:2017-11-28 15:03:12
【问题描述】:

使用 akka-http,您可以提供类型安全配置,如 here 所述,该配置位于 application.conf 中。所以一个缩小的配置可能如下所示:

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

我的问题是,如果我必须在应用程序中调用不同的外部服务,我会为这些服务创建不同的池。如何为这些调用不同外部服务的不同池更改这些配置(最大连接数、最大打开请求数)。

【问题讨论】:

    标签: scala http akka connection-pooling akka-http


    【解决方案1】:

    到目前为止,我为此找到的一个解决方案是,覆盖 connectionPoolSettings 并在创建 http 池时传递它:

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

    在这里我可以为maxOpenRequestsmaxConnections 提供适当的配置作为我的要求。

    【讨论】:

      猜你喜欢
      • 2016-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-08
      相关资源
      最近更新 更多