Results 1 to 3 of 3

Thread: Rejected items files & (Step/Item)Listener collaboration ?

  1. #1
    Join Date
    Jan 2006
    Posts
    13

    Question Rejected items files & (Step/Item)Listener collaboration ?

    Requirement: (Efficiently) generate a file containing all rejected (unparseable) records.

    I can wire an ItemReadListener, and in the method onReadError extract the malformed line from the Exception (an FlatFileParseException actually). My question is how to do this efficiently and cleanly. I don't want to open and close the file for each malformed record, but rather open it once and close it once. You might argue that the number of rejected records should be small, but anyway I'm trying for a clean and elegant solution.

    I was thinking about opening/closing the file in a StepExecutionListener. But then, how should the ItemReaderListener communicate with the StepExecutionListener? (i.e. get the File (OutputStream or whatever) from the StepExecutionListener).

    Is this the right direction? Isn't there an easier way (i.e. declarative).

    This seems harder than it should, so maybe there is an easier/better way that you might like to share.

    Thanks

  2. #2
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    your ItemReadListener can also implement the ItemStream interface. It would have callbacks along the step and chunk life cycles. It should help you open, flush, and close the file stream.

  3. #3
    Join Date
    Jan 2006
    Posts
    13

    Default

    Thanks, I opted to create a separate ItemStream and register it with the <streams> because I'm using a built in ItemReader.

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
  •