[SOLVED] Spring Batch Transaction issue


This Content is from Stack Overflow. Question asked by vaibhav

I am implementing application using spring Batch. I am following ItemReader, processor, ItemWriter Approach. I have created Partitioner component which is partitioning Data. Through ItemReader I am reading Data and processing it.
After processing I am writing back data in DB. Once job is finished, I observed there is some data missing in DB. Sometimes execution of the one partition fails.. It is random.
How Spring Batch creates Transactions. Is it transaction per Partition ? Or do we need to maintain thread synchronization ?


  • Total no of records – 1000
  • chunk – 100
  • Partition1 – 500
  • Partition2 – 500


Spring batch is gonna process by chunks. If a chunk fails (this means at least one item failed to process), the transaction is gonna be rolled back.

This Question was asked in StackOverflow by vaibhav and Answered by Leonardo Emmanuel de Azevedo It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?