javabatch-processingjsr352java-batchjberet

JSR352 - Single item read, multiple item write


In a project I'm working on we are reading a file in which every item (a record) read represents a variable number of items to be written in a destination database. This apparently seems to break the pattern of JSR352 by inflating a single chunk more than expected.

Does anyone has ever experienced this kind of problem? If yes, how has it been solved?


Solution

  • You can have a container object to hold all sub-items expanded from the single record in the input source. And the accumulated list of container objects will be passed to the item writer to write out to destination. You have full control of how the item writer works by implementing your own item writer class. For instance, the item writer class can write multiple records into destination.