Reputation: 279
I have a simple program working with Spring Batch Input reader, Writer. The purpose of the program is to simple read a csv file.
I have set the commit-interval
to 5. The csv file had only 5 records but for some reason the Writer was called 3 times although the commit-interval
was set to 5. I was expecting that the writer would be called only once based on my understanding that the item reader and processor would read each item line by line and then the writer would process all 5 at once. I guess I am not clear about the impact of commit-interval. Any advise?
Upvotes: 17
Views: 2658
Reputation: 499
I think you should have something like:
<job id="stepJob">
<step id="step1">
<tasklet>
<chunk reader="inputReader" writer="outputWriter" commit-interval="5"/>
</tasklet>
</step>
</job>
The last piece of the example step is the chunk tag where we define what a chunk is for the step. The commit-interval attribute is set at 5 in the example, meaning that no records will be written until 5 records are read and processed.
Upvotes: 1