Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

MultiResourceItemReader commit-interval and EOF  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm trying to implement a new behaviour on the MultiResourceItemReader from Spring-Batch, with no success so far.
Maybe i'm not looking in the right direction.

I have a few files to process (read and write in database). At the end of each file, I must create a report and move the file.


My problem is :
Let's say I have an interval-commit of 100.
FileA has 150 objects to read/write
FileB has a few unreadable objects (common error in my case)

1/ My batch will read the first 100 objects of fileA, commit.

2/ Then it reads the 50 items left of fileA, closes fileA, sends the report for the file, moves fileA to a new folder.
Then read the 50 first items from fileB, but there a RuntimeException occurs.
Because of the Exception, the transaction will rollback to the previous commit.

I am now in a state where I have only 100 items in my database, but fileA is considered done.

Is there any way to force MultiResourceItemReader to call the ItemWriter when reaching the end of a file ?
Am I doing something wrong ?
 
I am mighty! And this is a mighty small ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!