Results 1 to 2 of 2

Thread: can we have two writers for a job ? one for exception and one for success ??

Hybrid View

  1. #1
    Join Date
    Sep 2012
    Posts
    4

    Default can we have two writers for a job ? one for exception and one for success ??

    Hello Everyone ,

    Am working on POC of Spring Batch ,I have to compare the data in flat file and data base and need to route the matching rows to success table and not matching rows to exception table .How can we do this ? Is it possible to do with two writers ? please let me know .I got struck up here since two days and refering Spring batch in action but am not able to figure it out .

    Thanks

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    Is an exception actually thrown for the error items or are they just ones that are identified via processing as being "errors"? If it's the latter, you can writer your own ItemWriter that wraps two other ItemWriters. In your ItemWriter, you would determine what type of record it is and delegate the write to the appropriate writer.

    If it's the former, you could use a skip listener to do the writing for the error records.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •