I'm setting only one JobRunner per scheduler, but runners does not work that i want.
IJobStore jobStore = new MemoryJobStore();
IJobFactory jobFactory = new AllJobsFactory();
IJobRunner jr1 = new DefaultJobRunner(jobFactory, "JR1");
IJobRunner jr2 = new DefaultJobRunner(jobFactory, "JR2");
IJobRunner jr3 = new DefaultJobRunner(jobFactory, "JR3");
IJobRunner jr4 = new DefaultJobRunner(jobFactory, "JR4");
var s1 = new DefaultScheduler(jobStore, jr1);
var s2 = new DefaultScheduler(jobStore, jr2);
var s3 = new DefaultScheduler(jobStore, jr3);
var s4 = new DefaultScheduler(jobStore, jr4);
s1.Initialize();
s2.Initialize();
s3.Initialize();
s4.Initialize();
s1.Start(); s2.Start();
s3.Start(); s4.Start();
s1.CreateJob(new JobSpec("j1", "", "A", PeriodicTrigger.CreateDailyTrigger(DateTime.UtcNow.AddSeconds(1))), CreateJobConflictAction.Update);
s2.CreateJob(new JobSpec("j2", "", "B", PeriodicTrigger.CreateDailyTrigger(DateTime.UtcNow.AddSeconds(2))), CreateJobConflictAction.Update);
s3.CreateJob(new JobSpec("j3", "", "C", PeriodicTrigger.CreateDailyTrigger(DateTime.UtcNow.AddSeconds(3))), CreateJobConflictAction.Update);
s4.CreateJob(new JobSpec("j4", "", "D", PeriodicTrigger.CreateDailyTrigger(DateTime.UtcNow.AddSeconds(4))), CreateJobConflictAction.Update);
JR2 is running, AJob <-- I have set JobRunner1 to the Job A, but JR2 is handling job A
AJob started
JR2 is running, BJob
BJob started
JR1 is running, CJob <-- And here JR1 handling wrong job
JR3 is running, DJob
CJob started
DJob started
Begin Execute Method in DefaultJobRunner:
public IAsyncResult BeginExecute(JobExecutionContext context, AsyncCallback asyncCallback, object asyncState)
{ ...
job = jobFactory.GetJob(context.JobSpec.JobKey);
Console.WriteLine (_Name + " is running, " + job.GetType ().Name);
return new JobAsyncResult(job, asyncCallback, context, asyncState);
.. }