Search code examples
javajmsspring-batchbatch-processingsolace

Batch Message Consumption for JMSItemReader-Spring Batch


I'm working on a POC where requirement is to consume messages in a batch from a JMS queue and pass it to processor and writer in chain as per Spring batch Step..Spring Batch provides JMSItemReader as a out of box functionality but looks like it consumes messages one by one until there are no messages left in queue or receiver timeout is reached...As far as Chunk based step is concerned, Items are read into chunks,which are processed and then written within transaction as a chunk into another datastore..Here JMSItemReader doesn't read items in a batch..Is there any solution in Spring Batch world to consume messages in a batch from a queue to improve overall performance of an application?

I tried a lot of documentation but didn't find any appropriate solution for this use case..appreciate your help..Thank you


Solution

  • I believe the BatchMessageListenerContainer is what you are looking for. It allows you to read messages in batches.

    Note that this is not part of the standard library of readers/writers, but you can use it as is if you want or take inspiration and adapt it as needed.