AmazonS3连接管理 [英] AmazonS3 connection management

查看:602
本文介绍了AmazonS3连接管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有推荐的方式与AWS工作时来管理连接到AmazonS3?

Is there a recommended way to manage the connection to AmazonS3 when working with AWS?

典型的Amazon S3 code(来自亚马逊官方样片)通常是这样的?

Typical Amazon S3 code(taken from Amazon official sample) looks usually like this?

AmazonS3 s3 = new AmazonS3Client(...);
...
s3.putObject(new PutObjectRequest(bucketName, project.getName() + "/" + imageFile.getName(), imageFile));

以下是问题:

Following are the questions:

  • 这是一个好主意,保持在code所有人使用一个单一的AmazonS3Client还是最好在每次调用创建一个?

  • Is this a good idea to maintain a single AmazonS3Client used by everyone in the code or is it better to create one on every call?

有没有连接池的概念与MySQL例如工作时是怎样的?

Is there a concept of connection pool like when working with MySQL for example?

就像断线的问题(MySQL的比喻:MySQL的重新启动)有关,使得AmazonS3Client将变得无效,需要重新创造?什么是正确的方式来处理断开如果是这样?

Are questions like disconnection(MySQL analogy: MySQL was restarted) relevant such that the AmazonS3Client would become invalid and require re-creation? What would be the right way to handle a disconnection if so?

有没有人kwow什么fearures由Spring的集成提供了AWS为:<一href="https://github.com/spring-projects/spring-integration-extensions/tree/master/spring-integration-aws">https://github.com/spring-projects/spring-integration-extensions/tree/master/spring-integration-aws

Does anyone kwow what fearures are provided by the spring integration with aws at:https://github.com/spring-projects/spring-integration-extensions/tree/master/spring-integration-aws

THX。

推荐答案

我要重复的问题是明确的:

I'll repeat the questions to be clear:

这是一个好主意,保持由单一AmazonS3Client   大家在code或者是它更好地在每次调用创建一个?

Is this a good idea to maintain a single AmazonS3Client used by everyone in the code or is it better to create one on every call?

在Java SDK的所有客户端类是线程安全的,所以它通常是一个更好的主意,重新使用一个单一的客户端比实例化新的。或几个,如果你同时在多个地区或凭证操作。

All client classes in the Java SDK are thread safe, so usually it is a better idea to re-use a single client than instantiating new ones. Or a few, if you are operating concurrently on multiple regions or credentials.

有没有连接池的概念与MySQL例如工作时是怎样的?

Is there a concept of connection pool like when working with MySQL for example?

是的,有连接管理的客户端,特别是如果你使用 TransferManager 类,而不是 AmazonS3Client 直接。

Yes, there is connection management in the client, specially if you use the TransferManager class instead of the AmazonS3Client directly.

请参见:<一href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/TransferManager.html">http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/TransferManager.html

是像断线的问题(MySQL的比喻:MySQL的重新启动)   相关,使得AmazonS3Client将成为无效,并要求   娱乐?什么是正确的方式,如果处理断开   这样的吗?

Are questions like disconnection(MySQL analogy: MySQL was restarted) relevant such that the AmazonS3Client would become invalid and require re-creation? What would be the right way to handle a disconnection if so?

默认情况下,客户端不重与指数退避为可恢复的错误。 如果真的出现故障/断开连接,你需要处理异常适合您的应用程序。 请参见:<一href="http://docs.aws.amazon.com/general/latest/gr/api-retries.html">http://docs.aws.amazon.com/general/latest/gr/api-retries.html

By default, the client does retries with exponential backoff for recoverable errors. If it really fails/disconnects, you need to handle the exception as appropriate for your app. see: http://docs.aws.amazon.com/general/latest/gr/api-retries.html

有谁kwow什么fearures由Spring集成提供   与AWS的:   <一href="https://github.com/spring-projects/spring-integration-extensions/tree/master/spring-integration-aws">https://github.com/spring-projects/spring-integration-extensions/tree/master/spring-integration-aws

Does anyone kwow what fearures are provided by the spring integration with aws at: https://github.com/spring-projects/spring-integration-extensions/tree/master/spring-integration-aws

据提供声明实例化,注射和工具类更容易集成到Spring项目,以类似的方式也有帮手的JDBC,JMS,等...

It provide declarative instantiation, injection and utility classes for easier integration into Spring projects, in a similar way there are helpers for JDBC, JMS, etc...

有关更多AWS SDK的技巧和窍门,请参见:<一href="http://aws.amazon.com/articles/3604?_encoding=UTF8&jiveRedirect=1">http://aws.amazon.com/articles/3604?_encoding=UTF8&jiveRedirect=1

For more AWS SDK tips and tricks, see: http://aws.amazon.com/articles/3604?_encoding=UTF8&jiveRedirect=1

这篇关于AmazonS3连接管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆