c# - Cannot store a durable job because 'it already exists' -


What am I trying to do, to remove a trigger from my job and give it a new one I Users have been able to add a trigger only to each job, but I want to give them the option to remove that trigger and add new triggers to the same job.

To lose my job information, I have my job durable .

Then I'm getting the trigger that is related to that job and the usage

  scheduled. UnscheduleJob (trigger.Key);  

To remove the trigger (which is durable , whatever is my case, unless this job should also be undefined).

Now I know that the trigger has been removed, but my job is still there when I

  this job using the scheduled.ScheduleJob (Job, Nutrigger) I try to add my new trigger;  

I get an error:

The job could not be stored: Unable to store the job: 'MYGROUP.MYJOB', because already Is present with identity.

And that's what I know, but I still want to add this trigger to this job.

Why does this happen? And how can I add new triggers in old work without removing old job?

This is a fairly common error; As you might possibly know, the attempts to re-insert the sched.chedulejob (job, new trigger) to JobDetail in the QRTZ_JOB_DETAILS table. This violates compulsion because the table contains the compiler of the scheduler name, JobKey and JobGroup as the primary key. Quartz handles this form as well and gives you a meaningful error instead of reporting the primary key violation.

The solution is really simple as your old triggers change with the new

  ITrigger newTrigger = TriggerBuilder.Create () .CronSchedule with (new expression). Indenti (new trigger). STARTNOW (). Builder (); Schedule. ResetualId (existing trigger, new trigger);  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -