I saw this template called asynchronous write database or write behind template. This is a typical pattern supported by distributed cache products (Teracotta, Coherence, GigaSpaces, ...) because you do not want your cache updates to also include writing changes to the underlying database.
The complexity of this template depends on your tolerance for lost database updates. Due to the delay between shutting down and writing the result to the database, you may lose updates due to errors, power failures, ... (you will get an image).
I would suggest some queue for the completed results, which should be written to the database, and then process them in batches of 100 (using your example) OR after a while. The reason for using the time delay is also the coincidence with result sets that are not divisible by 100.
If you do not have sustainability / longevity requirements, you can do all this in the same process. If, however, you cannot tolerate any loss, you can replace the in-vm queue with a permanent JMS queue (slower but safer).
source share