Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 0b41aa2

Browse files
committed
Mention AWS CRT client in the README
* Use an explicit `S3AsyncClient.crtBuilder()` according to the warning in the logs for test * Some code clean up in the `S3MessageHandler`
1 parent f184d7b commit 0b41aa2

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ These dependencies are optional in the project:
4848
* `com.amazonaws:amazon-kinesis-producer` - for KPL-based `MessageHandler`
4949
* `software.amazon.awssdk:dynamodb` - for `DynamoDbMetadataStore` and `DynamoDbLockRegistry`
5050
* `software.amazon.awssdk:s3-transfer-manager` - for `S3MessageHandler`
51+
* `software.amazon.awssdk:aws-crt-client` - for `S3MessageHandler`
5152

5253
Consider to include an appropriate dependency into your project when you use particular component from this project.
5354

@@ -188,6 +189,8 @@ With this config you can send a message with the `java.io.File` as `payload` and
188189

189190
See more information in the `S3MessageHandler` JavaDocs.
190191

192+
NOTE: The AWS SDK recommends to use `S3CrtAsyncClient` for `S3TransferManager`, therefore an `S3AsyncClient.crtBuilder()` has to be used to achieve respective upload and download requirements.
193+
191194
### Outbound Gateway
192195

193196
The S3 Outbound Gateway is represented by the same `S3MessageHandler` with the `produceReply = true` constructor argument for Java Configuration.

src/main/java/org/springframework/integration/aws/outbound/S3MessageHandler.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import software.amazon.awssdk.transfer.s3.model.UploadDirectoryRequest;
3737
import software.amazon.awssdk.transfer.s3.model.UploadRequest;
3838
import software.amazon.awssdk.transfer.s3.progress.TransferListener;
39-
import software.amazon.awssdk.utils.BinaryUtils;
4039
import software.amazon.awssdk.utils.IoUtils;
4140
import software.amazon.awssdk.utils.Md5Utils;
4241

@@ -52,7 +51,6 @@
5251
import org.springframework.messaging.Message;
5352
import org.springframework.messaging.MessageHandlingException;
5453
import org.springframework.util.Assert;
55-
import org.springframework.util.DigestUtils;
5654

5755
/**
5856
* The {@link AbstractReplyProducingMessageHandler} implementation for the Amazon S3
@@ -298,16 +296,14 @@ else if (payload instanceof File fileToUpload) {
298296
if (payload instanceof InputStream inputStream) {
299297
byte[] body = IoUtils.toByteArray(inputStream);
300298
if (putObjectRequest.contentMD5() == null) {
301-
byte[] md5Digest = DigestUtils.md5Digest(body);
302-
putObjectRequestBuilder.contentMD5(BinaryUtils.toBase64(md5Digest));
299+
putObjectRequestBuilder.contentMD5(Md5Utils.md5AsBase64(body));
303300
inputStream.reset();
304301
}
305302
requestBody = AsyncRequestBody.fromBytes(body);
306303
}
307304
else if (payload instanceof File fileToUpload) {
308305
if (putObjectRequest.contentMD5() == null) {
309-
String contentMd5 = Md5Utils.md5AsBase64(fileToUpload);
310-
putObjectRequestBuilder.contentMD5(contentMd5);
306+
putObjectRequestBuilder.contentMD5(Md5Utils.md5AsBase64(fileToUpload));
311307
}
312308
if (putObjectRequest.contentLength() == null) {
313309
putObjectRequestBuilder.contentLength(fileToUpload.length());
@@ -320,8 +316,7 @@ else if (payload instanceof File fileToUpload) {
320316
}
321317
else if (payload instanceof byte[] payloadBytes) {
322318
if (putObjectRequest.contentMD5() == null) {
323-
String contentMd5 = Md5Utils.md5AsBase64(payloadBytes);
324-
putObjectRequestBuilder.contentMD5(contentMd5);
319+
putObjectRequestBuilder.contentMD5(Md5Utils.md5AsBase64(payloadBytes));
325320
}
326321
if (putObjectRequest.contentLength() == null) {
327322
putObjectRequestBuilder.contentLength((long) payloadBytes.length);

src/test/java/org/springframework/integration/aws/LocalstackContainerTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ static CloudWatchAsyncClient cloudWatchClient() {
7878
}
7979

8080
static S3AsyncClient s3AsyncClient() {
81-
return applyAwsClientOptions(S3AsyncClient.builder());
81+
return S3AsyncClient.crtBuilder()
82+
.region(Region.of(LOCAL_STACK_CONTAINER.getRegion()))
83+
.credentialsProvider(credentialsProvider())
84+
.endpointOverride(LOCAL_STACK_CONTAINER.getEndpoint())
85+
.build();
8286
}
8387

8488
static S3Client s3Client() {

0 commit comments

Comments
 (0)