Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable SqsTemplate to send more than 10 messages at once #1042

Open
tomazfernandes opened this issue Feb 9, 2024 · 5 comments
Open

Enable SqsTemplate to send more than 10 messages at once #1042

tomazfernandes opened this issue Feb 9, 2024 · 5 comments
Assignees
Labels
component: sqs SQS integration related issue status: ideal-for-contribution We agree it's nice to have but it is not team priority type: enhancement Smaller enhancement in existing integration

Comments

@tomazfernandes
Copy link
Contributor

As discussed here, currently SqsTemplate fails if more than 10 messages are provided in a batch with an error from AWS SDK.

We can add support for this use case by partitioning the message list in batches of 10, while also sending the batches in parallel.

This change would likely be around here:

protected <T> CompletableFuture<SendResult.Batch<T>> doSendBatchAsync(String endpointName,
Collection<Message> messages, Collection<org.springframework.messaging.Message<T>> originalMessages) {
logger.debug("Sending messages {} to endpoint {}", messages, endpointName);
return createSendMessageBatchRequest(endpointName, messages).thenCompose(this.sqsAsyncClient::sendMessageBatch)
.thenApply(response -> createSendResultBatch(response, endpointName,
originalMessages.stream().collect(Collectors.toMap(MessageHeaderUtils::getId, msg -> msg))));
}

@tomazfernandes tomazfernandes changed the title Enable SqsTemplate to send more than 10 messages in a batch Enable SqsTemplate to send more than 10 messages at once Feb 9, 2024
@tomazfernandes tomazfernandes added component: sqs SQS integration related issue status: ideal-for-contribution We agree it's nice to have but it is not team priority type: enhancement Smaller enhancement in existing integration labels Feb 15, 2024
@levys17
Copy link
Contributor

levys17 commented Mar 6, 2024

@tomazfernandes I started to work on it...If it's ok, can you assign this issue to me?

@techadri
Copy link
Contributor

@tomazfernandes I'd be happy to provide a PR for this topic, in case you (@levys17) aren't working on it anymore.

@levys17
Copy link
Contributor

levys17 commented Jun 11, 2024

@tomazfernandes I'd be happy to provide a PR for this topic, in case you (@levys17) aren't working on it anymore.

I didn't have time to finish that and I've barely worked on it in last weeks....so for me it'll be nice if you do that :D

@techadri
Copy link
Contributor

@tomazfernandes
Currently, doSendBatchAsync sends all messages in a single batch request using the sqsAsyncClient, ensuring that FIFO queues maintain the order of messages. If we change to partitioning messages and sending batches in parallel, only messages within each batch will retain order, but the order of the batches may vary. What are your thoughts on this?

@tomazfernandes
Copy link
Contributor Author

Oh, that's a great point.

I think the ideal solution would be partitioning batches per message group for fifo queues and then sending each batch in parallel.

A simpler solution would be sending batches in parallel for Standard queues and sequentially for FIFO queues.

WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: sqs SQS integration related issue status: ideal-for-contribution We agree it's nice to have but it is not team priority type: enhancement Smaller enhancement in existing integration
Projects
None yet
Development

No branches or pull requests

3 participants