Jan 10th, 2009, 10:33 PM
single instance of background job with tomcat?
This probably isn't a Spring Batch question I'm guessing but I don't know where else to ask.
In our setup we have multiple Tomcats behind a load balancer. I have a background task that will run once a day, via Quartz. All Tomcats will be using the same war so they will all run the job, but I need it so only one of them runs the job.
I'm looking for ideas for how to implement this. At the moment all I can think of is to use a table in a database with a unique constraint on a column, and each background process tries to insert today's date (yyyy-mm-dd) and the one that succeeds runs the job, and the ones that don't, do nothing.
Jan 12th, 2009, 07:01 AM
You could do something with a custom shared database. There is also support in Quartz for this feature directly (they call it "clustering"). But Spring Batch does it with the JobRepository, so maybe you could just code your JobLauncher client to ignore the exceptions it gets from JobAlreadyRunning and friends?
Jan 12th, 2009, 12:08 PM