Announcement Announcement Module
Collapse
No announcement yet.
MultiResourceItemReader & FlatFileItemReader - Processing multiple Files Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MultiResourceItemReader & FlatFileItemReader - Processing multiple Files

    Hi,

    I have a requirement where by I need to process multiple input files one after the other and record if there are any issues with the file.

    example - Say there are 3 files (File-1,2,3) in the directory

    a) records in File-1 has no errors - so I need to insert a record in DB with file name and status as "S" (success)
    b) records in File-2 has partial errors (10 out of 100 records has validation errors) so log it in DB table with file name and status as "P" (partial)
    c) all the records in File-3 are failed (100 out of 100 records has validation errors) so log it in DB table with file name and status as "F" (failure)

    How can I accomplish the above requirement by using FlatFileItemReader and send the file name and error count to Writer, how do I do that.

    Thanks.

  • #2
    The easiest way to handle this scenario is actually to use the latest build of Batch. BATCH-1854 addresses the need to be able to identify the resource a record came from (the exact scenario you're dealing with) by adding an interface called ResourceAware. By implementing this interface on your item, the reader will inject the resource the record came from so that you can find out the file name. Unfortunately, it's not in a released version yet and will be part of the 2.2.0 release which we are currently in development on. You can pull the latest development build, however and give it a shot. Any feedback you have is encouraged!

    Comment

    Working...
    X