从S3下载文件时引发Akka流异常

问题描述 投票:0回答:1

我正在尝试使用以下代码从S3下载文件:

     wsClient
      .url(url)
      .withMethod("GET")
      .withHttpHeaders(my_headers: _*)
      .withRequestTimeout(timeout)
      .stream()
          .map {             
            case AhcWSResponse(underlying) =>
                  underlying.bodyAsBytes
              }

运行此程序时,出现以下异常:

    akka.stream.StreamLimitReachedException: limit of 13 reached

这是因为我正在使用bodyAsBytes?这个错误是什么意思 ?我还看到了可能与以下警告消息有关的信息:

 blockingToByteString is a blocking and unsafe operation!
scala playframework akka
1个回答
0
投票
您正在获得StreamLimitReachedExpcetion,因为传入元素的数量大于最大值。

val MAX_ALLOWED_SIZE = 100 // OK. Future will fail with a `StreamLimitReachedException` // if the number of incoming elements is larger than max val limited: Future[Seq[String]] = mySource.limit(MAX_ALLOWED_SIZE).runWith(Sink.seq) // OK. Collect up until max-th elements only, then cancel upstream val ignoreOverflow: Future[Seq[String]] = mySource.take(MAX_ALLOWED_SIZE).runWith(Sink.seq)

您可以找到有关流处理here的更多信息
© www.soinside.com 2019 - 2024. All rights reserved.