Results 1 to 4 of 4

Thread: Writing invalid records to a file

  1. #1
    Join Date
    Jul 2008
    Posts
    5

    Default 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.

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    Use an ItemRead/WriteListener (depending on where the validation check is), or a skipLimit and an ItemSkipListener.

  3. #3
    Join Date
    Jul 2008
    Posts
    5

    Default

    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.

  4. #4
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    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
  •