cancel
Showing results for 
Search instead for 
Did you mean: 

Scheduling events on a multi instance application

ChrisPaine
Active Contributor
0 Kudos

Hello All,

I've got a question, which hopefully will be easy to solve, however, I'm not so sure.

I'm looking for a simple solution that will allow me to schedule tasks in my applications. I've very happily in the past been using Quartz - however, there is an inherent problem. I need only run the Quartz schedular in one instance of my application. As soon as I start running multiple instances (to enable scaling of application and for redundancy) then I need to ensure that only one of the instances is running the schedule. I've tried doing things like using database table and setting "locks" on a scheduled event with the first instance getting the lock being the one that carries out the event, hoping that the two instances don't access the table at the same time... I think this approach has some clear failings.

I'm really not sure how to do anything else though, as I don't think there is any way for an instance to be aware that others are running, nor to identify itself as the "primary" instance.

In other applications in the cloud it seems this is solved by subscribing to a scheduling service provided by a third party (which has APIs to create scheduled event and to trigger them). Is such a service available on HCP - or can you think of any other way to solve this issue?

Thanks!

Chris

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Chris,

Have you checked this article: http://www.quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigJDBCJobStoreClustering.... ?

It seems to be exactly what you are looking for.

Best regards,

Svetlin

ChrisPaine
Active Contributor
0 Kudos

Thanks, sorry should have replied earlier. Will check it out.  

ChrisPaine
Active Contributor
0 Kudos

Sounds very much like a solution currently use, where the schedule is on the DB and I use quartz to trigger each instance to read the DB and lock the schedule every minute.

Unfortunately doesn't work for those apps that don't have persistence associated with their account. For that use case I am yet to come up with a solution.

Cheers,

Chris

Answers (2)

Answers (2)

matt_steiner
Active Contributor
0 Kudos

Hi Chris,

this is another advice I received internally:

Look for clustered Quartz, see e.g.

http://www.quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigJDBCJobStoreClustering....

http://www.quartz-scheduler.org/documentation/quartz-2.2.x/tutorials/tutorial-lesson-11.html

there are also some samples


Cheers,

Matthias

matt_steiner
Active Contributor
0 Kudos

Hi ,

there's no such central service available I'm afraid. I've been using Quartz for this type of use-cases myself for as long as I can remember...

I see your struggle, one could argue that you could refactor the app and isolate the scheduler and only deploy it to one instance, but then you're running w/o a Fail-over scenario... #tricky

Let me think about it for a while and exchange thoughts with some colleagues - we'll get back to you!!!

Cheers,

matthias