amazon sqs java_使用 Amazon SQS Java Message Service (JMS) 用戶端 搭配其他 Amazon SQS 用戶端 - Amazon Simple Que...

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 Amazon SQS Java Message Service (JMS) 用戶端 搭配其他 Amazon SQS 用戶端

使用 Amazon SQS Java Message Service (JMS) 用戶端搭配 AWS SDK 會將 Amazon SQS 訊息大小限制為 256 KB。不過,您可以使用任何

Amazon SQS 用戶端建立 JMS 提供者。例如,您可以使用 JMS 用戶端 搭配Amazon SQS Java 延伸用戶端程式庫 傳送 Amazon SQS

訊息,其中包含對 Amazon S3 中的訊息承載 (最多 2 GB) 的參考。如需更多詳細資訊,請參閱「使用 Amazon S3 管理大型 Amazon SQS 訊息」。

以下 Java 範本程式碼會建立延伸用戶端程式庫的 JMS 提供者:AmazonS3 s3 = new AmazonS3Client(credentials);

Region s3Region = Region.getRegion(Regions.US_WEST_2);

s3.setRegion(s3Region);

// Set the Amazon S3 bucket name, and set a lifecycle rule on the bucket to

// permanently delete objects a certain number of days after each object's creation date.

// Next, create the bucket, and enable message objects to be stored in the bucket.

BucketLifecycleConfiguration.Rule expirationRule = new BucketLifecycleConfiguration.Rule();

expirationRule.withExpirationInDays(14).withStatus("Enabled");

BucketLifecycleConfiguration lifecycleConfig = new BucketLifecycleConfiguration().withRules(expirationRule);

s3.createBucket(s3BucketName);

s3.setBucketLifecycleConfiguration(s3BucketName, lifecycleConfig);

System.out.println("Bucket created and configured.");

// Set the SQS extended client configuration with large payload support enabled.

ExtendedClientConfiguration extendedClientConfig = new ExtendedClientConfiguration()

.withLargePayloadSupportEnabled(s3, s3BucketName);

AmazonSQS sqsExtended = new AmazonSQSExtendedClient(new AmazonSQSClient(credentials), extendedClientConfig);

Region sqsRegion = Region.getRegion(Regions.US_WEST_2);

sqsExtended.setRegion(sqsRegion);

以下 Java 範本程式碼會建立連線工廠:// Create the connection factory using the environment variable credential provider.

// Pass the configured Amazon SQS Extended Client to the JMS connection factory.

SQSConnectionFactory connectionFactory = new SQSConnectionFactory(

new ProviderConfiguration(),

sqsExtended

);

// Create the connection.

SQSConnection connection = connectionFactory.createConnection();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值