I have a Quartz cron job which initiates at a particular time in a day(say at 3:00 am) and runs well calling its itemreader and item writer. The problem is, it executes multiple times calling its item reader. For now, I have just kept a flag to stop it in the reader. Is there a better way to do this.
Is the commit-interval = 60 a problem ? as the no. of records the reader has to read is 10 .Having said that, the reader reads these 10 items and writer writes it to DB.Now again the reader is called which is a problem. The job xml is as below:
<batch:job id="AAA_job">
<batch:step id="step1">
<batch:tasklet>
<batch:chunk reader="XReader" writer="XWriter" commit-interval="60">
</batch:chunk>
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="XReader"
class="com.X.store.batch.X.jobs.XXReader"
scope="step">
<property name="AName" value="${AAA}"></property>
<property name="bu" ref="bu" />
</bean>
<bean id="XWriter" class="com.X.store.batch.X.jobs.XXWriter" scope="step" >
<constructor-arg ref="xDS" />
<property name="SSU" value="${ssu}" />
</bean>
I could probably understand this problem. Actually Quartz, being a cron job, reads data from one table and then writes to another in DB . So, at any point it does not understand for how long it has to keep reading the data since the data to be read is always available . It would work well in cases where the the data to be consumed is not available for consumption for the second time.