Nov 19th, 2012, 05:20 AM
Multi item reader
I am new to spring batch. I'm encoding a batch of spring. I have three input files (client.xml, campaign.txt and famliy.txt) that make up the java object (Message.java) that I should persist. I should read a line from each of the 3files and build the object, the object has properties in 3 files. How I can make a batch that has 3 itemReaders, so read the 3 files and build my object?
Client.xml-> name, id
Campaign.xml -> date, name_campaign
Family.xml -> famliy_name
Java Object: name, id, date, name_campaign, familiy_name
May be somting like this?
<chunk reader="itemReader" processor="processor" writer="tradeWriter">
<stream ref="fileItemReader" />
Nov 19th, 2012, 01:09 PM
What you're going to end up doing is creating a composite ItemReader implementation that wraps the readers for each of the three resources (client.xml, campaign.xml and family.xml). This ItemReader will be responsible for the assembly of the Message object based on the items each of the other ItemReaders return.