S3 クライアントの設定もできる AWS2S3Configuration を使用して、高度な設定を実行する場合があります。次の例に示すように、コンポーネント設定で S3 クライアントを作成および設定できます。
String awsBucketAccessKey = "your_access_key";
String awsBucketSecretKey = "your_secret_key";
S3Client s3Client = S3Client.builder().credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(awsBucketAccessKey, awsBucketSecretKey)))
.region(Region.US_EAST_1).build();
AWS2S3Configuration configuration = new AWS2S3Configuration();
configuration.setAmazonS3Client(s3Client);
configuration.setAutoDiscoverClient(true);
configuration.setBucketName("s3bucket2020");
configuration.setRegion("us-east-1");
String awsBucketAccessKey = "your_access_key";
String awsBucketSecretKey = "your_secret_key";
S3Client s3Client = S3Client.builder().credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(awsBucketAccessKey, awsBucketSecretKey)))
.region(Region.US_EAST_1).build();
AWS2S3Configuration configuration = new AWS2S3Configuration();
configuration.setAmazonS3Client(s3Client);
configuration.setAutoDiscoverClient(true);
configuration.setBucketName("s3bucket2020");
configuration.setRegion("us-east-1");
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
これで、ルートを初期化する前に、(上で作成した設定オブジェクトを使用して) S3 コンポーネントを設定し、configure メソッドでレジストリーに追加できます。
AWS2S3Component s3Component = new AWS2S3Component(getContext());
s3Component.setConfiguration(configuration);
s3Component.setLazyStartProducer(true);
camelContext.addComponent("aws2-s3", s3Component);
AWS2S3Component s3Component = new AWS2S3Component(getContext());
s3Component.setConfiguration(configuration);
s3Component.setLazyStartProducer(true);
camelContext.addComponent("aws2-s3", s3Component);
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow