Java Message Service を他の Amazon SQS クライアントで使用する - Amazon Simple Queue Service

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

Java Message Service を他の Amazon SQS クライアントで使用する

AWS SDK で Amazon SQS Java Message Service (JMS) クライアントを使用すると、Amazon SQS メッセージサイズは 256 KB に制限されます。ただし、任意のAmazon SQSクライアントを使用してJMSプロバイダを作成することができます。たとえば、Java用の Amazon SQS 拡張クライアントライブラリ とJMSクライアントを使用する場合、Amazon S3内のメッセージペイロード (最大2GB)への参照を含むAmazon SQSメッセージを送信することができます。詳細については、「Java と Amazon S3 を使用した大規模な Amazon SQS Amazon S3の管理」を参照してください。

次の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();