Announcement Announcement Module
Collapse
No announcement yet.
Rejected items files & (Step/Item)Listener collaboration ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


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

      Comment

      Working...
      X