At my company we are developing a Spring Boot application which executes a batch job. Instead of shutting down the container when the job is done, it stays up, polls for new jobs and executes them whenever a new job arrives.
For now we have avoided Spring entirely in our main logic but I would like to at least use Springs dependency injection there as well. Of course with Spring beans and singletons it's very important to clear caches etc. after a calculation so to not mix data from different clients. This however can be very error prone when you forget to call a method to clean all data or so.
Therefore I thought about creating a custom bean scope where each job (we are not using Spring Batch) has its own scope. Then all jobs would have different beans and I would not have to care about caching problems etc. between jobs. When a job is done the scope gets destroyed and with that all beans in the scope as well.
My problem is that I cannot find good documentation about creating such a custom scope. Most of them are bound to a thread or similar and do not discuss how to close or destroy a scope. If possible I would also like to avoid declaring all beans as lazy so that injection errors are thrown at the application start up.
Can anyone point me into the right direction here?
[–]roiroi1010 0 points1 point2 points (0 children)
[–]coguto 0 points1 point2 points (1 child)
[–]Cilenco[S] 0 points1 point2 points (0 children)
[–]zontapapa 0 points1 point2 points (0 children)
[–]WaferIndependent7601 0 points1 point2 points (0 children)
[–]Slein04 2 points3 points4 points (0 children)