首页 > 解决方案 > Camel AWS-S3 - 并非所有字节都从 S3ObjectInputStream 中读取,因此中止 HTTP 连接

问题描述

我正在使用 camel-aws 将文件轮询到远程 S3 存储桶以检查它是否已到达。我对文件的内容不感兴趣。

from("direct:my-route").
.from("aws-s3://my.bucket?useIAMCredentials=true&useAwsKMS=true&awsKMSKeyId=my-key-id&deleteAfterRead=false&operation=listObjects&includeBody=false&prefix=test1/etmp_xi_inbound.xml")
.log(" File detected: ${header.CamelAwsS3Key}")
.end();

我已将 includeBody 设置为 false 以不读取文件的内容,但是我收到以下警告:

WARN  c.a.s.s.i.S3AbortableInputStream - Not all bytes were read from the S3ObjectInputStream, aborting HTTP connection. This is likely an error and may result in sub-optimal behavior. Request only the bytes you need via a ranged GET or drain the input stream after use.

标签: amazon-s3apache-camelapache-camel-aws

解决方案


您是否将 autoCloseBody 设置为 true?似乎在较新版本的 Camel 中,它们可能会自动关闭 s3 连接,因此 autoCloseBody=true 意味着您正在尝试关闭已经关闭的连接,从而导致错误。


推荐阅读