如何增加(AKKA-HTTP客户端)singleRequest响应chuck大小

时间:2016-09-07 23:57:33

标签: scala akka akka-stream akka-http

我正在从URL读取HTTP响应流。 响应runForeach返回一个小块的流。 我想增加块大小。

我有一个application.conf文件,我在其中试验了以下内容(增加默认值),但没有任何改变。不确定哪个配置参数是我需要的。我一定是做错了。

application.conf:

SELECT ExtractValue( 
'<ns1:Request xmlns:ns1="http://www.sample.com/hic/event/request" xmlns:ns2="http://www.sample.com/hic/eventpayload/request">
  <ns1:createeventRequest>
    <ns1:eventPayLoad>
      <ns2:eventPayLoad>
        <Id>123456</Id>
      </ns2:eventPayLoad>
    </ns1:eventPayLoad>
  </ns1:createeventRequest>
</ns1:Request>',

'//Id[1]' ) AS result;

我的代码:

akka.http.host-connection-pool.client.parsing.max-chunk-size=50m
akka.http.host-connection-pool.client.parsing.max-chunk-ext-length=50m
akka.http.host-connection-pool.client.parsing.max-content-length=50m

谢谢。

2 个答案:

答案 0 :(得分:1)

max-chunk-size是一种防止填充内存的保护,如果服务器响应更大的块,它将无法通过请求,它不会以任何其他方式决定块的大小。

块大小由OS网络缓冲区,网络数据包大小,服务器响应http块等因素决定,你不能真正说“我想要50m块”。

您可以做的是将传入的ByteString连接到50mb块,concat是零复制操作,因此开销应该相当低。

在Akka Streams文档中有一个示例,说明如何创建一个自定义图形阶段,该阶段可以在此处执行“重新分配”:http://doc.akka.io/docs/akka/2.4/scala/stream/stream-cookbook.html#chunking-up-a-stream-of-bytestrings-into-limited-size-bytestrings

答案 1 :(得分:0)

由于文档描述了这些属性的设置 - link to documentation

  

重要提示:请注意,此部分设置可以覆盖   :akka.http.server.parsing中的相应设置,   akka.http.client.parsing或   akka.http.host-connection-pool.client.parsing

也许您应该尝试配置akka.http.host-connection-pool.client.parsingakka.http.server.parsing