Aug 11th, 2011, 06:47 AM
Commit-Interval not honored after roll back during write
Say my commit interval is 1000.
And during writing I get a error at 990th record which is skippable as per skip policy.
So a rollback will occur and the writer will start again writing the same records from record 1.
However, this time, It is commiting on each record. It does not honour commit interval. This is making the job dead slow.
Why the behavior is like that ?? Am I missing something in my configuration ??
Aug 11th, 2011, 10:14 PM
Originally Posted by nikunj_c
Progressed a bit.
Found that such a behaviour is mandatory for spring batch to isolate the bad item(s), basically it rollbacks the chunk and processes/writes each item with commit-rate=1 to find the bad one (in either processor or writer).
Ok. Got the point. The rollback will happen as soon as the writer hits the first exception. Say that exception occurs at Record 4 out of 1000 records. So the writer starts writing with commit interval 1 and finds the 4th item. Shouldn't it be good to write the remaining 996 records again as a chunk ?? Is it possible ???
I got comments from Michael that currently its not possible probably...
Can someone please help me out with this!!
Also, if my approach is wrong, what is the correct approach then ??
Sep 6th, 2011, 09:15 AM
I had the same problem.
A solution is to filter bad records with a processor instead of using a skippable exception in the writer.
Imho, the spring batch documentation does not explain clearly the replay mechanism in case of a skippable exception occurs in the writer, in particular the impact on the chunk processing.
Tags for this Thread