Closed georgiosd closed 8 years ago
Hi Georgios, I'd like to investigate this issue. Can you elaborate on what you're trying to do, how to reproduce it? It would be great if you could write a test which demonstrates the failure.
Tom, I think it's not relevant. The problem is in the quartz scheduling logic. Implementing the job store wasn't trivial and required diving into quartz scheduling logic and I might have missed a few things (including misfire handling).
My bad. I seem to be having this issue as well. Might be an issue with AcquireNextTriggers method.
Here's a test!
public class QuartzTests
{
public class TestJob : IJob
{
public void Execute(IJobExecutionContext context)
{
}
}
public class JobListener : IJobListener
{
public void JobToBeExecuted(IJobExecutionContext context)
{
}
public void JobExecutionVetoed(IJobExecutionContext context)
{
}
public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
{
WasExecuted = true;
}
public bool WasExecuted { get; private set; }
public string Name => "JobListener";
}
private readonly JobListener listener = new JobListener();
private readonly ITrigger trigger = TriggerBuilder.Create()
.StartAt(DateTime.Now - TimeSpan.FromHours(1))
.WithSimpleSchedule(s => s.WithMisfireHandlingInstructionFireNow())
.Build();
private readonly IJobDetail job = JobBuilder.Create<TestJob>()
.Build();
private void ScheduleTestJobAndWaitForExecution(IScheduler scheduler)
{
scheduler.ListenerManager.AddJobListener(listener);
scheduler.Start();
scheduler.ScheduleJob(job, trigger);
while (!scheduler.CheckExists(job.Key)) ;
scheduler.Shutdown(true);
}
[Fact]
public void InMemory()
{
var scheduler = StdSchedulerFactory.GetDefaultScheduler();
ScheduleTestJobAndWaitForExecution(scheduler);
Assert.True(listener.WasExecuted);
}
[Fact]
public void InRavenDB()
{
NameValueCollection properties = new NameValueCollection
{
// Normal scheduler properties
["quartz.scheduler.instanceName"] = "TestScheduler",
["quartz.scheduler.instanceId"] = "instance_one",
// RavenDB JobStore property
["quartz.jobStore.type"] = "Quartz.Impl.RavenDB.RavenJobStore, Quartz.Impl.RavenDB"
};
ISchedulerFactory sf = new StdSchedulerFactory(properties);
IScheduler scheduler = sf.GetScheduler();
ScheduleTestJobAndWaitForExecution(scheduler);
Assert.True(listener.WasExecuted);
}
}
Seems to me the secret sauce is at the method called at https://github.com/quartznet/quartznet/blob/master/src/Quartz/Impl/AdoJobStore/JobStoreSupport.cs#L2422
Thanks a lot! I'm on it..
How's it going? :)
Sorry got a little delayed because of work stuff :) I'll give it another try tomorrow.
Problem was that the trigger's NextFireTimeUtc field wasn't being updated in case of a misfire. Please let me know if your problem is solved...
Thanks! Are you pushing a new nuget?
I did. Version 1.0.4 has the fix.
Sweet! I presume the test passes so no need to try it myself. Thank you for your attention to this!
Hey guys,
I can't, for the life of me, get a job executed after it has gone past the fire time. It seems to me that the misfire handling parameter is not used when the scheduler is fetching jobs.
Thoughts?
Thanks, Georgios