GetNextFireTimeUtc always returns the same thing (?)

341 views
Skip to first unread message

okdk4321

unread,
Jun 9, 2010, 3:20:58 AM6/9/10
to Quartz.NET
I'm new to C# and Quarts.Net. I was playing around with the examples
that came with Quartz.Net.
In Example 5 (MisFireExample.cs), in the wait loop after the scheduler
is started, I added a trigger.GetNextFireTimeUtc() call to try to
print out the next fire time after each iteration.

try
{
// sleep for ten minutes for triggers to file....
// I commented out the following line.
//Thread.Sleep(TimeSpan.FromMinutes(10));
// and added the following for loop.

for (int i = 0; i < 20; i++)
{
Thread.Sleep(TimeSpan.FromSeconds(3));

log.Info(string.Format("Next Fire Time: {0}",
trigger.GetNextFireTimeUtc().Value.ToLocalTime()));
}

}
catch (ThreadInterruptedException)
{
}


I expected the next fire time to change after each execution of the
job, but for some reason, the next fire time is always the same as the
initial fire time, as shown below.

Can anyone tell me what I am doing wrong? Thanks!


00:15:09:046 [INFO] Quartz.Examples.Example5.MisfireExample - -------
Initializing -------------------
00:15:09:156 [INFO] Quartz.Core.SchedulerSignalerImpl - Initialized
Scheduler Signaller of type: Quartz.Core.SchedulerSignalerImpl
00:15:09:156 [INFO] Quartz.Core.QuartzScheduler - Quartz Scheduler v.
1.0.2.3 created.
00:15:09:156 [INFO] Quartz.Simpl.RAMJobStore - RAMJobStore
initialized.
00:15:09:156 [INFO] Quartz.Impl.StdSchedulerFactory - Quartz
scheduler 'ExampleDefaultQuartzScheduler' initialized
00:15:09:156 [INFO] Quartz.Impl.StdSchedulerFactory - Quartz
scheduler version: 1.0.2.3
00:15:09:156 [INFO] Quartz.Examples.Example5.MisfireExample - -------
Initialization Complete -----------
00:15:09:156 [INFO] Quartz.Examples.Example5.MisfireExample - -------
Scheduling Jobs -----------
00:15:09:171 [INFO] Quartz.Examples.Example5.MisfireExample -
group1.statefulJob1 will run at: Wednesday, June 09, 2010 12:15:15 AM
and repeat: -1 times,
every 3 seconds
00:15:09:171 [INFO] Quartz.Examples.Example5.MisfireExample -
group1.statefulJob2 will run at: Wednesday, June 09, 2010 12:15:15 AM
and repeat: -1 times,
every 3 seconds
00:15:09:171 [INFO] Quartz.Examples.Example5.MisfireExample - -------
Starting Scheduler ----------------
00:15:09:171 [INFO] Quartz.Core.QuartzScheduler - Scheduler
ExampleDefaultQuartzScheduler_$_NON_CLUSTERED started.
00:15:09:171 [INFO] Quartz.Examples.Example5.MisfireExample - -------
Started Scheduler -----------------
00:15:12:171 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM
00:15:15:015 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing
instance of Job 'group1.statefulJob1',
class=Quartz.Examples.Example5.StatefulDumbJob
00:15:15:015 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing
instance of Job 'group1.statefulJob2',
class=Quartz.Examples.Example5.StatefulDumbJob
00:15:15:031 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job
group1.statefulJob2
00:15:15:031 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job
group1.statefulJob1

---group1.statefulJob2 executing.[Wed, 09 Jun 2010 00:15:15 GMT]

---group1.statefulJob1 executing.[Wed, 09 Jun 2010 00:15:15 GMT]
00:15:15:171 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM
00:15:18:171 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM
00:15:21:171 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM
00:15:24:171 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM
-group1.statefulJob2 complete (1).
-group1.statefulJob1 complete (1).
00:15:25:046 [DEBUG] Quartz.Core.JobRunShell - Trigger instruction :
NoInstruction
00:15:25:046 [DEBUG] Quartz.Core.JobRunShell - Trigger instruction :
NoInstruction
00:15:25:062 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing
instance of Job 'group1.statefulJob2',
class=Quartz.Examples.Example5.StatefulDumbJob
00:15:25:093 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing
instance of Job 'group1.statefulJob1',
class=Quartz.Examples.Example5.StatefulDumbJob
00:15:25:093 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job
group1.statefulJob2
00:15:25:109 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job
group1.statefulJob1

---group1.statefulJob2 executing.[Wed, 09 Jun 2010 00:15:25 GMT]

---group1.statefulJob1 executing.[Wed, 09 Jun 2010 00:15:25 GMT]
00:15:27:171 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM
00:15:30:187 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM
00:15:33:187 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM
-group1.statefulJob2 complete (2).
00:15:35:187 [DEBUG] Quartz.Core.JobRunShell - Trigger instruction :
NoInstruction
00:15:35:203 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing
instance of Job 'group1.statefulJob2',
class=Quartz.Examples.Example5.StatefulDumbJob
-group1.statefulJob1 complete (2).
00:15:35:218 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job
group1.statefulJob2

---group1.statefulJob2 executing.[Wed, 09 Jun 2010 00:15:35 GMT]
00:15:35:234 [DEBUG] Quartz.Core.JobRunShell - Trigger instruction :
NoInstruction
00:15:35:312 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing
instance of Job 'group1.statefulJob1',
class=Quartz.Examples.Example5.StatefulDumbJob
00:15:35:328 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job
group1.statefulJob1

---group1.statefulJob1 executing.[Wed, 09 Jun 2010 00:15:35 GMT]
00:15:36:187 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM
00:15:39:187 [INFO] Quartz.Examples.Example5.MisfireExample - Next
Fire Time: 6/9/2010 12:15:15 AM

Valentin Briones

unread,
Jun 14, 2010, 4:59:21 PM6/14/10
to Quartz.NET
Still looking for an answer to this.   My previous post via the web seem to have gotten reformatted really narrow, so I am sending this via e-mail to see
if it get formatted better.   Also, I think I sent the output for the original example, which has a lot of extra garbage in it.   Here is a better (hopefully) view of it.
I tried to bold the next fire time values to make them easy to see.  I don't know if that will go across.


15:51:54:312 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - ------- Initializing -------------------
15:51:54:421 [INFO]  Quartz.Core.SchedulerSignalerImpl - Initialized Scheduler Signaller of type: Quartz.Core.SchedulerSignalerImpl
15:51:54:421 [INFO]  Quartz.Core.QuartzScheduler - Quartz Scheduler v.1.0.2.3 created.
15:51:54:421 [INFO]  Quartz.Simpl.RAMJobStore - RAMJobStore initialized.
15:51:54:421 [INFO]  Quartz.Impl.StdSchedulerFactory - Quartz scheduler 'ExampleDefaultQuartzScheduler' initialized
15:51:54:421 [INFO]  Quartz.Impl.StdSchedulerFactory - Quartz scheduler version: 1.0.2.3
15:51:54:421 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - ------- Initialization Complete -----------
15:51:54:421 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - ------- Scheduling Jobs -----------
15:51:54:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - group1.statefulJob1 will run at: Mon, 14 Jun 2010 20:51:55 GMT and repeat: 5 times, every 8 seconds
15:51:54:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - ------- Starting Scheduler ----------------
15:51:54:437 [INFO]  Quartz.Core.QuartzScheduler - Scheduler ExampleDefaultQuartzScheduler_$_NON_CLUSTERED started.
15:51:54:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - ------- Started Scheduler -----------------
15:51:55:015 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing instance of Job 'group1.statefulJob1', class=Quartz.Examples.Example5.StatefulDumbJob
15:51:55:031 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job group1.statefulJob1

---group1.statefulJob1 executing.[Mon, 14 Jun 2010 15:51:55 GMT]
15:51:57:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
 -group1.statefulJob1 complete (1).
15:51:59:046 [DEBUG] Quartz.Core.JobRunShell - Trigger instruction : NoInstruction
15:52:00:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
15:52:03:015 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing instance of Job 'group1.statefulJob1', class=Quartz.Examples.Example5.StatefulDumbJob
15:52:03:015 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job group1.statefulJob1

---group1.statefulJob1 executing.[Mon, 14 Jun 2010 15:52:03 GMT]
15:52:03:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
15:52:06:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
 -group1.statefulJob1 complete (2).
15:52:07:015 [DEBUG] Quartz.Core.JobRunShell - Trigger instruction : NoInstruction
15:52:09:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
15:52:11:000 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing instance of Job 'group1.statefulJob1', class=Quartz.Examples.Example5.StatefulDumbJob
15:52:11:000 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job group1.statefulJob1

---group1.statefulJob1 executing.[Mon, 14 Jun 2010 15:52:11 GMT]
15:52:12:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
 -group1.statefulJob1 complete (3).
15:52:15:000 [DEBUG] Quartz.Core.JobRunShell - Trigger instruction : NoInstruction
15:52:15:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
15:52:18:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
15:52:19:000 [DEBUG] Quartz.Simpl.SimpleJobFactory - Producing instance of Job 'group1.statefulJob1', class=Quartz.Examples.Example5.StatefulDumbJob
15:52:19:000 [DEBUG] Quartz.Core.JobRunShell - Calling Execute on job group1.statefulJob1

---group1.statefulJob1 executing.[Mon, 14 Jun 2010 15:52:19 GMT]
15:52:21:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
 -group1.statefulJob1 complete (4).
15:52:23:000 [DEBUG] Quartz.Core.JobRunShell - Trigger instruction : NoInstruction
15:52:24:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Next Fire Time:  6/14/2010 3:51:55 PM
15:52:24:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - ------- Shutting Down ---------------------
15:52:24:437 [INFO]  Quartz.Core.QuartzScheduler - Scheduler ExampleDefaultQuartzScheduler_$_NON_CLUSTERED shutting down.
15:52:24:437 [INFO]  Quartz.Core.QuartzScheduler - Scheduler ExampleDefaultQuartzScheduler_$_NON_CLUSTERED paused.
15:52:24:437 [DEBUG] Quartz.Simpl.SimpleThreadPool - shutdown complete
15:52:24:437 [INFO]  Quartz.Core.QuartzScheduler - Scheduler ExampleDefaultQuartzScheduler_$_NON_CLUSTERED Shutdown complete.
15:52:24:437 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - ------- Shutdown Complete -----------------
15:52:24:453 [INFO]  Quartz.Examples.Example5.MisfireExample_vcb - Executed 4 jobs.
Example run successfully.
15:52:24:500 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
15:52:24:500 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
15:52:24:515 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
15:52:24:562 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
15:52:24:906 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
15:52:24:906 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
15:52:24:906 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
15:52:24:906 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
15:52:24:906 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
15:52:24:906 [DEBUG] Quartz.Simpl.SimpleThreadPool - WorkerThread is shut down
--
Thanks,
  Valentin Briones

Kristjan Laane

unread,
Apr 16, 2016, 6:30:49 AM4/16/16
to Quartz.NET, valentin...@gmail.com
same problem here, reported the issue here https://github.com/quartznet/quartznet/issues/352
hopefully someone with appropriate knowledge can review the GetFireTimeAfter method in DailyTimeIntervalTriggerImpl (im guessing the bug is somewhere there)

Marko Lahma

unread,
Jun 5, 2016, 10:10:12 AM6/5/16
to Quartz.NET, valentin...@gmail.com

Try this code instead to get correct output:

                for (int i = 0; i < 20; i++)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(3));

                    var tempTrigger = sched.GetTrigger(trigger.Key);
                    log.Info(string.Format("Next Fire Time:  {0}", tempTrigger.GetNextFireTimeUtc().Value.ToLocalTime()));
                }

This key here is that RAMJobStore clones the trigger when stored and retrieved (mimics how AdoJobStore works and protects job store from external alteration via trigger references). So the the trigger that you have have does not get its state updated. If you really wanted to check how trigger fires you would just create the instance and retrieve fire times.

-Marko
Reply all
Reply to author
Forward
0 new messages