Results 1 to 3 of 3

Thread: single instance of background job with tomcat?

  1. #1
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default 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. #2
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    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?

  3. #3
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •