Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple readers in spring batch

Tags:

spring-batch

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

like image 748
karthick m Avatar asked Nov 05 '25 08:11

karthick m


1 Answers

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.

like image 182
Michael Minella Avatar answered Nov 09 '25 08:11

Michael Minella



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!