My question relates to Spring batch and transactions.
Say I've chosen a commit-interval of 50 for one of my steps.
Also suppose I have 1000 records in all and amongst those records one will cause the itemWriter to fail thereby causing a rollback of the entire chunk (50 records in my example).
What are the stategies to make sure that the 49 valid records are written to database after the job has completed (and ignored the problematic chunk)?
After some researching, I came up with the following:
If an item writer fails to commit a chunk (here 50 items) thereby causing a rollback, Spring Batch will rerun each item of the problematic chunk individually with one commit/transaction for each item.
Therefore, all 49 items will be present in database except the one item that caused Spring Batch to roll back the chunk.