-
Jul 28th, 2008, 04:00 PM
#1
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
#2
Use an ItemRead/WriteListener (depending on where the validation check is), or a skipLimit and an ItemSkipListener.
-
Aug 6th, 2008, 12:19 AM
#3
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
#4
Then you'll need to do the validation in the writer.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules