The application is using Spring boot 2.7.0. I have an API - "/stopRunningJobs" and when this is triggered all the running spring batch jobs/APIs are stopped. Now, while this API is stopping all the running jobs, there may be a possibility of another API being called, which may end up in the "in-progress" or "completed" state rather than the "STOPPED" state. So, two inputs are needed-
- Is there a way in a spring boot, we can stop all other incoming requests to this container or application when "/stopRunningJobs" API is running ?
- Or, can we queue up all the incoming requests until "/stopRunningJobs" API processing is over and it resumes post that.
Any input is appreciated. Thank you
CodePudding user response:
After doing some research - I could not find any inbuilt annotation on this. We will have to manually queue all the incoming requests and persist the request at the database layer with all the needed parameters. When the API - "/stopRunningJobs" is completed, we can write a method or an API to fetch all the queued request from the database, iterate it along with the param and invoke the API asynchronously.
Thank you.