简体   繁体   中英

Where to keep intermediate results of a spring batch job?

For context, I have a table with parcels that were delivered to different delivery countries. I want to find the average parcel count per delivery country per week day(Sun, Mon, Wed etc) for the past 5 weeks.

I am supposed to use Spring Batch for this. From how I see, I could fetch the parcels as batches to do the calculation. But I won't be able to write the final result until I have processed all the parcels. Am I using the wrong concept for batches here? Or does Spring Batch provide a way to keep intermediate results?

Spring batch just triggers code to execute. I would write the results into a explicit batch database with all results related to the actual batch run. In that way you do not spam the production database and also might keep the results for further documentation/debugging. If necessary, you may delete it after a certain period. That way, if that batch database gets crashed because of any reason, it won't interfere with production data and you have the data sorted by the batch run.

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