We have a REST API written in Spring Boot. Part of this application is a Spring Batch job that runs everyday. I wanted an exit code to be returned to the shell script starting the application once the Spring Batch job was complete, so I added a System.exit()
in my main method. Only then did I realize that this would cause the entire Spring Boot application to exit, which we don't want. I am looking for a way for the Spring Batch job to execute, return an exit code to the shell script that's calling it, and have the Spring Boot application still up and running.
I know that I can have the Spring Batch job scheduled to run at specific times as part of the running Spring Boot application, and it would run at those times while the entire application was up. BUT the trouble with that is that the application runs on OLTP, and we can't have the Spring Batch jobs running on OLTP since that would try to execute the same job on multiple OLTP servers at the same time, causing some instances of the job to fail.
For the above reason, we are looking to run the application on OLTP as well as a single batch server. Our aim is that the Spring Batch jobs will run through the batch server, and the application will end with a System.exit()
on this batch server (so that it can return an exit code to the shell script), while the actual Spring Boot application will be made available through OLTP, and won't have a System.exit()
statement. I don't see how this is possible, but if all this even remotely makes sense to someone else, I would love to hear their opinion.