他の Amazon SQS クライアントでの Amazon SQS Java Message Service (JMS) クライアントの使用 - Amazon Simple Queue Service

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

他の Amazon SQS クライアントでの Amazon SQS Java Message Service (JMS) クライアントの使用

Amazon SQS Java Message Service (JMS) クライアントでのAWSSDK では Amazon SQS メッセージのサイズが 256 KB に制限されます。ただし、任意の Amazon SQS クライアントを使用して JMS プロバイダを作成することもできます。たとえば、Java 用の Amazon SQS 拡張クライアントライブラリで JMS クライアントを使用して、Amazon S3 内のメッセージペイロード (最大 2 GB) への参照を含む 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();