TransferManager 上传后是否可以重复使用?

Is TransferManager reusable after upload?

我正在使用 TransferManager 将文件上传到我的 s3 存储桶。虽然文档说尽可能重用一个实例,但它也说一旦传输完成就应该调用关闭。

文档的相关部分:

TransferManager is responsible for managing resources such as connections and threads; share a single instance of TransferManager whenever possible. TransferManager, like all the client classes in the AWS SDK for Java, is thread safe. Call TransferManager.shutdownNow() to release the resources once the transfer is complete.

这是字面上的理解,还是我们可以重用对象并在应用程序关闭时调用关闭?

一些背景知识:我们之前使用相同的 s3 客户端为每次上传创建一个 TransactionManager,但我们开始在某些上传中抛出 AbortedException

在这里回答我自己的问题:我们在测试和生产中重用了传输管理器,没有任何问题。

A​​WS SDK 相关查询在此聊天中得到解答:https://gitter.im/aws/aws-sdk-java

搜索与"aws client reusable"的聊天记录应该指向团队中某人的相关评论。

上面链接的聊天中相关评论的抄本:

soutchay Feb 13 2018 17:08 - Hi everyone, we have a Spring Boot Java application using aws sdk to upload objects to S3. We have a TransferManager bean and are using it to perform an upload and a waitForUploadResult. The documentation on the TransferManager says to call shutdownNow()after waitForUploadResult completes.

AdityaVivek Mar 06 2018 11:08 - Hi everyone, I have the same doubt as @soutchay , can TransferManager be reused after upload or does it have to be shutdown immediately?

jaramd Mar 06 2018 04:17 - Hi Aditya, you can reuse the TransferManager object, which is thread safe actually. It has a executor pool with control number of threads. So you cannot span more that thread pool size.