Rory Primrose
Rory Primrose

Reputation: 633

Running Quartz.Net jobs concurrently across multiple Azure instances

I am putting together a system that needs to scale out scheduled work. I am using Quartz.Net to schedule multiple jobs via CRON triggers. The design of the jobs is such that they are safe for concurrent execution across multiple Azure role instances.

All the information available seems to be about ensuring that Quartz.Net does not execute the same job at the same time across multiple machines which is the behaviour I am currently seeing.

I actually need the opposite (essentially a pool not a cluster of Quartz.Net schedulers). For example, I have JobX that I want to execute at TimeY across two role instances. I want two executions to occur at the same time. I currently can only get Quartz to execute one.

The implementation currently uses a single web role with two instances. Longer term this will scale out with many worker role instances also executing the same scheduled tasks. Each role instance spins up its own scheduler instance and starts it. They use the same quartz configuration which is as follows.

<?xml version="1.0" encoding="utf-8" ?>
<quartz>

  <add key="quartz.scheduler.instanceId" value="AUTO"/>
  <add key="quartz.scheduler.instanceName" value="QuartzScheduler" />

  <!-- Configure Thread Pool -->
  <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
  <add key="quartz.threadPool.threadCount" value="10" />
  <add key="quartz.threadPool.threadPriority" value="Normal" />

  <!-- Configure Job Store -->
  <add key="quartz.jobStore.clustered" value="true"/>
  <add key="quartz.jobStore.misfireThreshold" value="60000" />
  <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
  <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" />
  <add key="quartz.jobStore.tablePrefix" value="quartz.QRTZ_" />
  <add key="quartz.jobStore.dataSource" value="config" />
  <add key="quartz.dataSource.config.provider" value="SqlServer-20" />

  <add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz" />
  <add key="quartz.plugin.xml.fileNames" value="~/QuartzJobs.config" />
</quartz>

How do I get Quartz.Net to execute concurrent jobs across multiple machines?

Upvotes: 0

Views: 2418

Answers (1)

Rory Primrose
Rory Primrose

Reputation: 633

I have confirmed that the solution is to use the RAMJobStore rather than the ADOJobStore. Each scheduler running in each role instance will execute the same jobs and triggers at the same time. This allows for a pool of Quartz.Net schedulers to run the same jobs concurrently.

Upvotes: 4

Related Questions