Announcement Announcement Module
Collapse
No announcement yet.
single instance of background job with tomcat? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

    Thanks

  • #2
    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?

    Comment


    • #3
      Originally posted by Dave Syer View Post
      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?
      Excellent; thanks.

      I was suspecting/hoping that Spring Batch had something that could help me.

      Comment

      Working...
      X