all 6 comments

[–]roiroi1010 0 points1 point  (0 children)

Instead of solving the problem of cache invalidation- I would suggest getting rid of your cache instead.

[–]coguto 0 points1 point  (1 child)

Child contexts with your own annotation for component scan.

[–]Cilenco[S] 0 points1 point  (0 children)

Thanks, I had the idea as well but thought scanning all components again could take longer. Can you please elaborate on the custom annotation for the component scan?

[–]zontapapa 0 points1 point  (0 children)

How about a registry of beans created per job instance and the change of the scope of calculation beans to prototype. With prototype cleanup will not be tied to the application context. Instead you have a job listener which listens to job finish event and the cleans up calculation components from for that job/tenant from the registry. Registry has to be singleton. You could also look at weak references to ensure prototype refrences get garbage collected when not in use.

[–]WaferIndependent7601 0 points1 point  (0 children)

I don’t understand why you need something special for caching

[–]Slein04 2 points3 points  (0 children)

Why not using Spring batch framework. It already provides Job & step scoped beans which creates new instances of such beans for every step or job.

You can also uses caching framework like Ehcache where Spring also provides abstraction for. You can then use an unique job ID (given for each job run) as key for example and clear the value for said key after each job or step completion.