I 'm using the clustering option and I have some problems with it:
When I using with two machines the jobs that I created runs in the beginning without connection to theirs definition. for example: if I defined the job to run once a ten second it can run every two second on the beginning and only from the 2th running it's correctly - every ten second.
The two machines take the same job in the same minute (but not in the same millisecond) and run the job twice together, I tried to use the lock handler property but maybe I didn't define it well..
This is my code:
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "TestSchedulerNECH";
properties["quartz.scheduler.instanceId"] = "instance_one";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "200";
properties["quartz.threadPool.threadPriority"] = "Normal";
properties["quartz.jobStore.misfireThreshold"] = "60000";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "false";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
properties["quartz.jobStore.clustered"] = "true";
properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz";
properties["quartz.dataSource.default.connectionString"] = "Server=localhost;Database=mydb;Trusted_Connection=False;User=admin;Password=123456";
properties["quartz.dataSource.default.provider"] = "SqlServer-20";
ISchedulerFactory sf = new StdSchedulerFactory(properties);
IScheduler sched = sf.GetScheduler();
string schedId = sched.SchedulerInstanceId;
for (int i = 1; i <= 5; i++)
{
IJobDetail job = JobBuilder.Create<SimpleRecoveryJob>()
.WithIdentity("job_" + i, schedId)
.RequestRecovery(false)
.Build();
ITrigger trigger = TriggerBuilder.Create()
.StartAt(DateBuilder.FutureDate(10, IntervalUnit.Second))
.WithCronSchedule("0/10 * * * * ? *")
.ForJob(job)
.EndAt(DateBuilder.FutureDate(3, IntervalUnit.Minute))
.Build();
sched.ScheduleJob(job, trigger);
}
sched.Start();
Someone can help me?
I know this is an old thread, but if we want to disallow concurrent execution, we have to add the DisallowConcurrentExecution attribute to the job class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With