0

We're using Quartz.net and need the jobs to fire more often. Job is set to fire in 3 seconds but it usually takes 15-30 seconds before it's run.

I've also tried (without result) < add key="quartz.jobStore.clusterCheckinInterval" value="1000" />

Thanks for any help PS. We're using 2.1.2.400 if it matters

Our configs

  <quartz>
    <add key="quartz.scheduler.instanceName" value="ServerScheduler" />
    <add key="quartz.scheduler.instanceId" value="AUTO" />
    <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
    <add key="quartz.threadPool.threadCount" value="10" />
    <add key="quartz.threadPool.threadPriority" value="2" />
    <add key="quartz.jobStore.misfireThreshold" value="60000" />
    <add key="quartz.jobStore.clusterCheckinInterval" value="1000" />
    <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
    <add key="quartz.jobStore.useProperties" value="false" />
    <add key="quartz.jobStore.dataSource" value="default" />
    <add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
    <add key="quartz.jobStore.clustered" value="true" />
    <add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
    <add key="quartz.dataSource.default.connectionString" value="Data Source=xyz..." />
    <add key="quartz.dataSource.default.connectionStringName" value="RecDB" />
    <add key="quartz.dataSource.default.provider" value="SqlServer-20" />
  </quartz>

Code

var jobSilentDetail = CreateFutureJobDetail(new JobKey(JobName(shoppingListNotification.Id)),
                                                typeof(JobShoppinglistNotification),
                                                string.Format("Job bla bla"));

jobSilentDetail.JobDataMap["ShoppingListNotification"] = shoppingListNotification;

var startJobAt = DateTime.Now.AddSeconds(3);
SaveFutureJob(jobSilentDetail, startJobAt);




protected void SaveImmediateJob(IJobDetail jobDetail)
{
    Scheduler.ScheduleJob(jobDetail, CreateImmediateTriggerFor(jobDetail));
}

protected void SaveFutureJob(IJobDetail jobDetail, DateTime startTime)
{
    Scheduler.ScheduleJob(jobDetail, CreateFutureTriggerFor(jobDetail, startTime.ToUniversalTime()));
}


protected ITrigger CreateImmediateTriggerFor(IJobDetail jobDetail)
{
    return CreateOneRunTriggerFor(jobDetail, QuartzJobType.Immediate, DateTime.Now);
}

protected ITrigger CreateFutureTriggerFor(IJobDetail jobdetail, DateTime startTime)
{
    return CreateOneRunTriggerFor(jobdetail, QuartzJobType.Future, startTime);
}


private static ITrigger CreateOneRunTriggerFor(IJobDetail jobDetail, QuartzJobType quartzJobType, DateTime startTime)
{
    var trigger = TriggerBuilder
    .Create()
    .WithIdentity(jobDetail.Key.Name, quartzJobType.ToString())
    .WithSimpleSchedule()
    .StartAt(startTime.ToUniversalTime())
    .Build();

    return trigger;
}
bg_user
  • 41
  • 5
  • Can you provide the rest of your configuration values? specifically the threadpool.threadcount and Threadpriority – Alioza Aug 26 '15 at 19:49
  • Added the configs in my question above. Replaced the db connectionstring with xyz... though – bg_user Aug 27 '15 at 07:37
  • I have a similar configuration but I'm using the SimpleSemaphore for the lock handler: Quartz.Impl.AdoJobStore.SimpleSemaphore, Quartz. It's the only difference I see. – Alioza Sep 02 '15 at 09:27
  • Alioza, how long does it take for a job to fire for you? Mine take 20-30 seconds before it runs. I want it to run in 3 seconds. – bg_user Sep 02 '15 at 12:48
  • It usually takes just a few seconds, most times it's immediately. It also depends on the load of the system, if you have other heavy processing that will also delay your triggers. – Alioza Sep 02 '15 at 13:01
  • Alioza what version are you using? SimpleSemaphore might be slightly faster but not by much. I have no load, just adding one. Did you also add a 3 seconds delay like my code? – bg_user Sep 03 '15 at 10:33
  • I'm working with 2.3. As for the delays, I either launch jobs immediately or in 5 seconds. – Alioza Sep 03 '15 at 14:22
  • Ok maybe it's my version then (2.1.2.400) that are that slow. – bg_user Sep 04 '15 at 05:18

2 Answers2

0

I'd strongly suggest trying out the latest version as you have brought up in the comments. There was a bug with AdoJobStore job handling taking some time in some cases that was fixed in version 2.2.3. Please also not that when upgrading to >= 2.2 series a (minor) database schema upgrade is needed.

You can see the release history in here.

It's always advisable to check release notes for later releases if you are experiencing issues.

Marko Lahma
  • 6,586
  • 25
  • 29
  • Marko Lahma thanks for your reply. Yeah a upgrade is always beneficial. I wasn't sure a upgrade would help or quartz.net was not suitable for jobs with short notice (so this was a expected behaivor). – bg_user Sep 07 '15 at 06:03
  • We have now upgraded to last version of Quartz.net. It's a little bit faster 15-20 seconds. But still to slow. Will make any difference or do we need to hack the project? In JobStoreSupport.cs I saw this: ClusterCheckinInterval = TimeSpan.FromMilliseconds(7500); Or has ClusterCheckinInterval nothing to do with the frequency of how often Quartz check for new jobs? – bg_user Jan 26 '16 at 11:34
0

Well we never got Quartz.net to fire fast enough. Took about 15 seconds instead of the needed 3. So we totally changed approach.

Instead of MANY future jobs that should be run 3 seconds after they where created. We created ONE recurring job that fires every 2 seconds and write logic (with a different db table) to figure out what items have passed the 3 second waiting time.

Hope this helps someone else out there that get stuck with the same problem.

bg_user
  • 41
  • 5