How to perform multiple write from single item/line using Spring-Batch? -


how can perform multiple write single item given data using spring-batch?

do need read input x times , create object write or read input once , perform multiple write?

input:

  • id, label1, detail1, detail2, detail3

output1:

  • id, label1

output2:

  • id, detail1
  • id, detail2
  • id, detail3

spring batch provides compositeitemwriter takes list of itemwriters. writer calls each writer, in turn, each item. if have item needs written 2 different files in different formats, can use compositeitemwriter write each item each file. in case, you'd use multiple jdbcbatchitemwriters.

you can read more compositeitemwriter in documentation here: http://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/item/support/compositeitemwriter.html

an example of itemwriter shown in spring batch samples here: https://github.com/spring-projects/spring-batch/blob/master/spring-batch-samples/src/main/resources/jobs/compositeitemwritersamplejob.xml


Comments