From 3a54c48c4116fd513a3e38a2e7db9b88a130555c Mon Sep 17 00:00:00 2001 From: Nikita Bahliuk Date: Sun, 26 Dec 2021 14:37:30 +0200 Subject: [PATCH] Closes #68 Make sure we send updated SendMessageBatchRequest entries when message payload is transfered through s3. --- .../amazon/sqs/javamessaging/AmazonSQSExtendedClient.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java b/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java index 0a3f73b..7520706 100644 --- a/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java +++ b/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java @@ -617,16 +617,22 @@ public SendMessageBatchResponse sendMessageBatch(SendMessageBatchRequest sendMes List batchEntries = new ArrayList<>(sendMessageBatchRequest.entries().size()); + boolean hasS3Entries = false; for (SendMessageBatchRequestEntry entry : sendMessageBatchRequest.entries()) { //Check message attributes for ExtendedClient related constraints checkMessageAttributes(entry.messageAttributes()); if (clientConfiguration.isAlwaysThroughS3() || isLarge(entry)) { entry = storeMessageInS3(entry); + hasS3Entries = true; } batchEntries.add(entry); } + if (hasS3Entries) { + sendMessageBatchRequest = sendMessageBatchRequest.toBuilder().entries(batchEntries).build(); + } + return super.sendMessageBatch(sendMessageBatchRequest); }