4

I have a requirement to implement in Spring batch,I need to read from a file and from a DB ,the data needs to be processed and written to an email

I have gone through the spring batch documentation but was unable to find a CHUNKtasklet which would read data from multiple readers

SO essentially I have to read from 2 different sources of data(one from file and another from DB,each will need to have its own mapper)

Regards Tar

karthick m
  • 51
  • 1
  • 2
  • possible duplicate of [Spring batch Job read from multiple database](http://stackoverflow.com/questions/21304364/spring-batch-job-read-from-multiple-database) – Luca Basso Ricci Apr 26 '15 at 10:19
  • Its all depends on, what is the relation between data in file and data in db, could you explain that bit more? – Karthik Prasad Apr 28 '15 at 08:13

1 Answers1

6

I see two options depending on how the data is structured:

  1. Spring Batch relies heavily on composition when building batch components. One option would be to create a custom composite ItemReader that delegates to a other readers (ones Spring Batch provides or otherwise) and provides the logic to assemble a single object based on the results of those delegated ItemReaders.
  2. You could use an ItemReader to provide the base information (say from a database) and use and ItemProcessor to enrich the item (say reading from a file).

Either of the above are normal ways to handle this type of input scenario.

Michael Minella
  • 20,843
  • 4
  • 55
  • 67