I am revamping a dataloader that reads from flat file and batchinsert using jdbctemplate for every 500 items. I am using java executor fixed thread pool that submits tasks, which does reading each file and batchupdate. For example when reading first file, if it fails during 3rd batchinsert ,all the previous batchinsert for this file needs to be rollbacked. The task should continue with next file and create a new transaction for insert. I needed a code that can do this . Currently I am using transactiontemplate and wrapping the batchinsert code inside doInTransactionwithoutcallbackand during exception in catch block calling transaction status.setrollbackonly. But I need a code which can create new transaction for next file irrespective of whether last file failed or succeded.setting propagation to requires new solves it?
I am revamping a dataloader that reads from flat file and batchinsert using jdbctemplate
Share
As Sean commented, you should not reinvent the whole thing, and use Spring Batch instead.
Spring Batch will allow you to:
And it is already there => coded, tested and awesome.