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

Extend SQSMessageProducer to facilitate sending batches of JMS messages with SendMessageBatchRequest #81

Open
Mobe91 opened this issue Sep 18, 2019 · 6 comments

Comments

@Mobe91
Copy link

Mobe91 commented Sep 18, 2019

Currently, the SQSMessageProducer only allows sending messages one by one. However the SQS supports SendMessageBatchRequest to send multiple messages with one request. While the JMS API does not support this, it would still be a useful and important feature.

@robin-aws
Copy link
Collaborator

Hi there! This isn’t something we have any plans to add, but you have a couple of options. You can use the buffered asynchronous client included with the SQS SDK to automatically merge individual SendMessage requests into SendMessageBatch requests: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-client-side-buffering-request-batching.html. Or you can always use the SQS API directly if you want to create your own batches requests. It depends on how much benefit you’re getting from using the JMS API.

@Mobe91
Copy link
Author

Mobe91 commented Sep 19, 2019

You can use the buffered asynchronous client included with the SQS SDK

I have already had a look on the buffered asynchronous client but from looking at the code, JMS messages sent through SQSMessageProducer are still being sent synchronously and therefore no batching will take place.

Or you can always use the SQS API directly if you want to create your own batches requests. It depends on how much benefit you’re getting from using the JMS API.

Sure, but since I also use JMS on the receiver side without problems it would be nice to keep using it on the sender side - otherwise I would have to duplicate all the message conversion stuff that is taken care of by the SQSMessageProducer.

Would you be willing to accept a PR that adds such a capability to SQSMessageProducer?

@robin-aws
Copy link
Collaborator

The buffered asynchronous client will batch together synchronous calls as well: it holds calls open for up to 200 ms to wait for enough concurrent requests to fill a batch, at the cost of a bit of extra latency. The that 200 ms is configurable - see the maxBatchOpenMs setting here: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/buffered/QueueBufferConfig.java#L43

@robin-aws
Copy link
Collaborator

I'm also certainly willing to consider a PR for adding batch sending to SQSMessageProducer though! I don't see anything wrong with adding that capability, but it's also appealing to achieve that batching while sticking to the generic JMS interfaces.

@Mobe91
Copy link
Author

Mobe91 commented Sep 19, 2019

The buffered asynchronous client will batch together synchronous calls as well

True but the calling thread will block until sending is complete. But it should work if I use multiple threads that invoke send.

but it's also appealing to achieve that batching while sticking to the generic JMS interfaces

The JMS 2.0 API has support for asynchronous message sending. Do you have any plans on supporting JMS 2.0?

@Mobe91
Copy link
Author

Mobe91 commented Sep 19, 2019

True but the calling thread will block until sending is complete. But it should work if I use multiple threads that invoke send.

But this will destroy message ordering - I am using a FIFO SQS queue. So not a real solution.

Mobe91 added a commit to ordami/amazon-sqs-java-messaging-lib that referenced this issue Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants