gpt4 book ai didi

aws-java-sdk - TransferManager 上传后可以重用吗?

转载 作者:行者123 更新时间:2023-12-04 04:04:01 26 4
gpt4 key购买 nike

我正在使用 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抛出一些上传。

最佳答案

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

AWS 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.

关于aws-java-sdk - TransferManager 上传后可以重用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49125775/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com