i new msmq, quartz, , services. have service send notification email if exception thrown. trying find way pause or stop service once email sent don't receive same exception email on , on again. need email once. far have tried:
- _scheduler.deletejob(jobkey);
- _scheduler.unschedulejob(triggerkey);
- _scheduler.shutdown();
- _scheduler.interrupt(jobkey);
- servicecontroller.stop();
- servicecontroller.pause();
- _scheduler.reschedulejob(key, exceptiontrigger); <- on ride old trigger new 1 has interval time of zero
my job , trigger code work expected:
public void createregistration() { this._scheduler = stdschedulerfactory.getdefaultscheduler(); createjob(); createtrigger(); registerwithscheduler(); } public void createjob() { _scheduler.start(); this._job = jobbuilder.create<recievemessagejob>() .withidentity("receivemessagesjob", this._messagegroupname) .build(); } public void createtrigger() { _trigger = triggerbuilder.create() .withidentity(this._triggername, this._messagegroupname) .startnow() .withsimpleschedule(x => x .withintervalinminutes(1) .repeatforever()) .build(); } public void registerwithscheduler() { _scheduler.schedulejob(_job, _trigger); }
in receivemessagejob job class exception errors in execute method (execute(ijobexecutioncontext context)) , call pauseservice() if need be. here can see various attempts stop or pause service.
public void pauseservice() { triggerkey triggerkey = this._trigger.key; jobkey jobkey = this._job.key; // define new trigger //itrigger exceptiontrigger = triggerbuilder.create() // .withidentity("exceptiontrigger", this._messagegroupname) // .startnow() // .withsimpleschedule(x => x // .withintervalinminutes(0)) // .build(); // tell scheduler remove old trigger given key, , put new 1 in place //_scheduler.reschedulejob(key, exceptiontrigger); //_scheduler.deletejob(jobkey); //_scheduler.unschedulejob(triggerkey); //_scheduler.shutdown(); //_scheduler.interrupt(jobkey); //servicecontroller servicecontroller = new servicecontroller("messagingservice"); //servicecontroller.stop(); //servicecontroller.pause(); }
i can't figure out why none of attempts have worked. see wrong in code or know of different way? in advance!
i'm not sure understand how scheduler tied service. mean windows nt service? scheduler run job starts service? either way, when there's error in service, have service shut down. scheduler have nothing that.
Comments
Post a Comment