Saturday 15 January 2011

How to properly detect and then remove jobs that cannot be recovered using Quartz.net? -



How to properly detect and then remove jobs that cannot be recovered using Quartz.net? -

for various valid reasons, jobs in job store old , can no longer recovered. instance, when job class no longer part of .net assemblies after refactor. i'm wondering how gracefully grab these problems when scheduler starts, , delete unrecoverable jobs.

when app starts, (abridged):

ischeduler scheduler = <create scheduler , jobstore object> try{ scheduler.start() } grab {} try{ scheduler.start() } grab {} try{ scheduler.start() } grab {}

if phone call start() 3 times, scheduler starts. reason have hacky thing because start() throw exceptions unrecoverable, old jobs.

failure occured during job recovery. , could not load type 'myoldclassname' assembly 'myassembly'.

i want gracefully remove broken jobs , avoid these exceptions. in actual code, log these exceptions.

is there improve way this?

i found 1 way this. calling before start() cures problem.

var jobs = this._scheduler.getjobkeys(groupmatcher<jobkey>.anygroup()); foreach (var jobkey in jobs) { seek { // effort access jobtype. if fails, know it's broken type t = _scheduler.getjobdetail(jobkey).jobtype; } grab (jobpersistenceexception ex) { if (ex.innerexception != null) { if (ex.innerexception.gettype() == typeof(typeloadexception)) { _scheduler.deletejob(jobkey); } } else { // log } } grab (exception ex) { // log } }

quartz-scheduler quartz.net

No comments:

Post a Comment