'Existing Job' error when storing Quartz.NET job on Azure [closed]

旧巷老猫 提交于 2019-12-25 21:22:13

问题


How do I create adojobstore with out throwing the following error:

 Unable to store job because one already exists with this identification.

Can I read from the database and check if the job does not exist then add it to the scheduler? Is that the recommended way of doing?

Is it necessary to Shutdown the scheduler on Azure?


回答1:


As you are using AdoJobStore, you are saving jobs in DB so you sure can check the existence of a job in table separately before scheduling a job otherwise just use AddJob with the same JobID and be sure to create a durable job.

The job which can be reused must be durable, means jobs still exist even when it is not scheduled, which means there is no trigger attached to it. An example of durable job is as below:

dJob = new JobDetail("consolidate-attendance", "daily-attendance-group", 
              ConsolidateAttendance.class,
              /* volatile */ false, 
              /* durable */ true,
              /* recover */ false);
sched.addJob(jobContext, dJob, false);

ScheduleJob has two version, one accept job with trigger and another job so you need to be sure which one you will use. If you have already define the job then you cannot use ScheduleJob which accepts both a job and a trigger because internally the scheduler would try to add the job to itself and fail.

When job is already defined, you just need to bind job with trigger through via Trigger class and use the scheduleJob that only accepts a trigger.

This should work and you don't need to shutdown the scheduler.



来源:https://stackoverflow.com/questions/11215314/existing-job-error-when-storing-quartz-net-job-on-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!