Jul 28th, 2008, 04:00 PM
Writing invalid records to a file
I am new for spring-batch framework. I want to write the invalid records to a file and want to continue with the next valid records. For example if a input flat file contains 20 records and any 5 are invalid, i want to write those invalid records to a file and want to process all the valid records. It will be good if I can get the corresponding value objects for the invalid records, so that I can mark(using some delimiter) the exact invalid field in the invalid records and can write the same to a file.
Is there any build-in support available for the above said requirement in the spring-batch framework? If not, can anybody throw some idea for the same.
Jul 30th, 2008, 02:31 AM
Use an ItemRead/WriteListener (depending on where the validation check is), or a skipLimit and an ItemSkipListener.
Aug 6th, 2008, 12:19 AM
Thank you for the reply.
I implemented the suggestion you gave. But the problem is I need the whole object for which the validation failed as I need to log the "complete line" where validation failed.
The ItemReadListener interface has a method called "onReadError" from which I can get the exception thrown but not the complete object for which validation failed.
Aug 6th, 2008, 09:40 AM
Then you'll need to do the validation in the writer.
Tags for this Thread