

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

# Java Message Service を他の Amazon SQS クライアントで使用する
<a name="sqs-jms-client-with-sqs-clients"></a>

 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 メッセージの管理](sqs-s3-messages.md)」を参照してください。

次の Java コード例では、拡張クライアントライブラリの JMS プロバイダーを作成します。

この例をテストする前に、「[JMS と Amazon SQS を使用するための前提条件](prerequisites.md)」の前提条件を参照してください。

```
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();
```