Aug 15th, 2011, 11:08 AM
How do you shutdown spring batch and allow an application to exit?
My application is going to be called by a CRON job to do some background processing and I am using Spring Batch to wire up what processing needs to be done. I found that even after all my jobs are run, my application does not exit. I need to do a System.exit(0) to force the application to stop. This doesn't seem right. How can I shutdown spring batch when I'm done with it so my application can exit?
Aug 15th, 2011, 05:29 PM
It probably is not a spring batch issue at all. It sounds more like you have non-deamon Threads running even after your main thread has finished executing.
Aug 15th, 2011, 06:52 PM
Where does your 'main' live - is this Spring Batch in a web app, or standalone? If it's standalone, did you write the 'main' method yourself?
If you have a simple job launcher, it's just going to run that job and complete. At that point, if that's all your 'main' does, it should exit.
Last but not least, you can take a look at the Spring Batch Admin, it provides hooks to start/pause/stop jobs, which I've found very useful.