简体   繁体   中英

How to read and perform batch processing using spring batch annotation config

I have 2 different file with different data. The file contains 10K record per day.

Ex:
Productname price date
T shirt,500,051221
Pant,1000,051221


Productname price date
T shirt,800,061221
Pant,1800,061221

I want to create final output file by checking price difference by todays and yesterdays file.

Ex: 
Productname price 
T shirt,300
Pant,800

By using spring batch I have to do this. I have tried with batch configuration by creating two different step. but its only able to read the data. but unable to do the processing. because here I need the data of both file for processing. but in my case its reading one step after another.

Could anyone help me on this with some sample code.

I would suggest to save FlatFile data into the database for yesterday's and today's date (may be two separate tables or in a same table if you can identify difference two records easily). Read this stored data using JdbcCursorItemReader or PagingItemReader and perform calculation/logic/massaging of data at the processor level and create a new FlatFile or save into DB as per convenience. OOTB Spring Batch does not provide facility to read data and perform calculation.

Suggestion - Read data from both the FlatFile keep it in cache and read from the cache and do the further processing.

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