Announcement Announcement Module
No announcement yet.
Restart with several FlatFileItemWriter Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Restart with several FlatFileItemWriter


    I have a job that writes 3 FlatFileItemWriter. When the job failed, only one lastMarkedByteOffsetPosition seems to be stored in DB with the key name = name of the class that is always the same between the 3 files. Then when I restart my job, if the size of my file is > lastMarkedByteOffsetPosition of the last write file in the first execution of my job, a ResetFailedException is thrown in checkFileSize method of FlatFileItemWriter.

    To resolve this problem, I have only set a different name to each FlatFileItemWriter.
    Is it possible to do something to avoid this problem by default in Spring Batch?

    Thanks in advance.

  • #2
    The name property is exactly for that purpose - because the execution context is shared you need a way to use different keys for instances of the same class.

    I don't see a good way to handle this transparently, but suggestions are certainly welcome. The composite item writer could figure this out I think, but it is an edge case that would probably pollute the simple default implementation - we could provide a subclass, but remembering to use the subclass seems equally hard as remembering to give names to the writers.