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

226 views Asked by At

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.

1

There are 1 answers

2
Prateek On

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.