0

Is it safe to run multiple instances of the quartz.net scheduler? If so, how do I do it?

Candy Chiu
  • 6,579
  • 9
  • 48
  • 69
  • 1
    can you explain the scenario which needs multiple scenarios? If you want to feed jobs through one scheduler and run jobs in another you can create scheduler for feeding jobs with property ; – Krishna Feb 11 '13 at 17:35
  • 1
    I need to run some jobs sequentially AND on one thread. A scheduler with 1 thread and another with a regular thread pool would solve my problem. – Candy Chiu Feb 11 '13 at 17:55

1 Answers1

0

You can use quartz_jobs.xml to configure jobs and create StatefulJobs and use job chaining for running jobs sequentially in one thread scheduler(pointing to RAMJobStore); another scheduler pointing to data store can run simultaneously http://quartz-scheduler.org/documentation/faq#FAQ-chain

If you need to persist all jobs to single database, you can use 2 schedulers with clustering but you won't get to choose which job runs on which scheduler, so your jobs will run sequentially but may not run on single thread scheduler. 2schedulers can be run, if having 2 quartz table sets with different prefix is not an issue. http://quartz-scheduler.org/documentation/quartz-1.x/cookbook/MultipleSchedulers

Krishna
  • 134
  • 4
  • you can have single thread scheduler pointing to quartz tables with some prefix, using configuration – Krishna Feb 11 '13 at 19:33
  • I should need only one configure files for the two schedulers. they differ by the number of threads in the pool. I do not wish to create two separate config files as future sync between the two would be a nightmare. And I am not using a database store. How do I achieve this? – Candy Chiu Feb 11 '13 at 20:28
  • properties can be set in code; NameValueCollection scheduler1Properties = new NameValueCollection(); properties["quartz.scheduler.instanceName"] = "SingleThreadScheduler"; properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz"; properties["quartz.threadPool.threadCount"] = "1"; – Krishna Feb 11 '13 at 20:33
  • I still need to use the config file to specify all properties except one. Is there a function that takes a NameValueCollection that overrides the settings in the file? – Candy Chiu Feb 11 '13 at 20:55
  • you can pass the collection to scheduler creation constructor. Why don't you access that one property you want to keep in config file and set it in collection ? – Krishna Feb 11 '13 at 20:59