简体   繁体   中英

Processing two files in a spring batch

Have a requirement to read files in spring batch, process it and persist it as one feed. One feed contains 50% of the information. When i have to persist the final result from the feeds, i need combine them using a common field and persist it as if like one item. Please see example below.

Feed1 fields: A|B|C|D|E
Feed2 fields: A|I|J|K|L

Final information that i need to persist is like:

A|B|C|D|E|I|J|K|L

Please suggest how i can achieve this in my spring batch job.

Thanks.

If your input files would have been sorted you could have created a custom ItemReader implementation that performs a merge-sort on the files.

If sorting the input files is not an option, I think you'll need to store one of the input files temporarily into a data store. Then you can read from the second input file and enrich the records with the fields retrieved from the data store in your processor.

(很晚)答案,但是您可以使用像这样的插件来处理排序和后续合并操作: https : //github.com/upcrob/spring-batch-sort-merge

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM