Results 1 to 2 of 2

Thread: Multi item reader

  1. #1
    Join Date
    Nov 2012
    Posts
    1

    Default Multi item reader

    Hi all,

    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?


    <tasklet>
    <chunk reader="itemReader" processor="processor" writer="tradeWriter">
    <streams>
    <stream ref="fileItemReader" />
    </streams>
    </chunk>
    </tasklet>

    Any example?


    Thank you!

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    348

    Default

    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.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •