Search code examples
quartz-schedulerjob-scheduling

Use same quartz instance both clustered and non clustered way for same set of Quartz table


I have a requirement where some of my quartz job should run in Clustered way (Only one node out of three should run the job) and some jobs to run in non clustered way (All 3 nodes out of 3 should run the job).

Now my questions is can I use the same set of tables in a data source for both this requirement.

Here is what i can do for achieving the same.

  1. 2 quartz.properties one for clustered instance and one for non clustered.
  2. Both instances of cluster will start at application startup.
  3. So the jobs configured under the non clustered scheduler will be saved with the name of scheduler as NON_CLST_SCHE in jobs table, in the same table under different scheduler name.

Is this the right way to use the quartz ? Do we face any problem of data corruption problems?

As per quartz Documentation @ http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-11.html it says that Never fire-up a non-clustered instance against the same set of tables that any other instance is running against. You may get serious data corruption, and will definitely experience erratic behavior.

Now if above explanation is true what is the way out for my requirement.

Any help is much appreciated, thanks in advance !


Solution

  • I think that your approach is fine (assuming that all non clustered schedulers that access the same database have a unique scheduler name).

    In my oppinion the warning refers to the case when you have multiple, non clustered instances with the same scheduler-name that run against the same database. E.g. a scheduler could only see jobs, triggers and so on from a JDBC-Jobstore if the associated SchedulerName of that job (trigger,...) matches that of the scheduler.