I have one spring batch application which can be run from command line. The flow of the batch job is when it starts , it reads the message from queue and transform then and write to db. Now for this i am using JmsItemReader from spring batch and inside read() method I have my logic. Now question is there might be a chance that when this process start, there is no message exist on the queue, in this scenario I want to stop processing whole batch.
How can this be achieved in spring batch? Basically what happens when you use JmsItemReader, it continuously ping jms broker and to read message and then sleep for a period of time. Now if there is no message to process then why should we keep the batch process running and let it consume CPU. I want it to run again next day as per schedule.
Thanks
this behaviour comes from the default configuration for the jmstemplate which is provided by spring-jms
default value for timeOut is indefinite
with this value, messageconsumer.receive() will be used
so you need to set a timeout value for the jmstemplate
then receive(long timeOut) will be used
if you use a value of -1 the call happens immediately