Announcement Announcement Module
Collapse
No announcement yet.
Writing invalid records to a file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Use an ItemRead/WriteListener (depending on where the validation check is), or a skipLimit and an ItemSkipListener.

    Comment


    • #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.

      Comment


      • #4
        Then you'll need to do the validation in the writer.

        Comment

        Working...
        X