awslabs / amazon-sqs-java-extended-client-lib

An extension to the Amazon SQS client that enables sending and receiving messages up to 2GB via Amazon S3.
Apache License 2.0
211 stars 109 forks source link

sendMessageBatch method sends the original messages instead of references to s3 to SNS #68

Closed shotmk closed 2 years ago

shotmk commented 2 years ago

sendMessageBatch is sending the original messages instead of references to s3 bucket. Files are uploaded to s3 too though.

Looks like we are building batchEntries in AmazonSQSExtendedClient:618 - AmazonSQSExtendedClient:628, but we forget to update the builder with new entries before submitting the request to underlying sqsClient instance.

List<SendMessageBatchRequestEntry> batchEntries = new ArrayList<>(sendMessageBatchRequest.entries().size());

        for (SendMessageBatchRequestEntry entry : sendMessageBatchRequest.entries()) {
            //Check message attributes for ExtendedClient related constraints
            checkMessageAttributes(entry.messageAttributes());

            if (clientConfiguration.isAlwaysThroughS3() || isLarge(entry)) {
                entry = storeMessageInS3(entry);
            }
            batchEntries.add(entry);
        }

        return super.sendMessageBatch(sendMessageBatchRequest);

Probably we want to do smth like:

return super.sendMessageBatch(sendMessageBatchRequest.toBuilder().entries(batchEntries).build());