amazon-sqs-java-messaging-lib
amazon-sqs-java-messaging-lib copied to clipboard
Extend SQSMessageProducer to facilitate sending batches of JMS messages with SendMessageBatchRequest
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.
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.
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?
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
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.
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?
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.