c# - scheduling web services in Quartz.Net - windows service or singleton -
i have web app that's running bunch of data processing jobs on backend, rather bogging down server want schedule jobs , decided give quartz.net go.
the obvious thing guess create scheduler windows service. have similar running, find windows service bit of pain several reasons (one of them being if crashes needs manually restarted).
i thinking more elegant way create service singleton, questions be:
if have several ashx backend calls, can declare this:
public static ischeduler scheduler { get; private set; }
in each ashx , singleton across backend calls?
can check running jobs
scheduler.getcurrentlyexecutingjobs();
, shut scheduler down if there aren't any?the main reason want use quartz.net limit amount of jobs running concurrently, create simple jobs run now. read, if there no threads available, job rejected , handled once threads become available again.
scheduler.getcurrentlyexecutingjobs();
return rejected/waiting jobs well?- how start scheduler if it's down? down because iis closed or because code closed if no jobs running. ideally, if add new job, scheduler start up. guess, maintain own list of jobs in array , manage - or there way via quartz directly? or better make scheduler permanent - iis app pool recycle + quartz scheduling?
since have multiple questions, i've copied them down here clarity:
- if have several ashx backend calls, can declare this...
if have multiple classes defined ashx, each class new instance of scheduler. no, declaring private static property on each 1 not give singleton. if declare public static property in global.asax file, yes, you'll have singleton.
- can check running jobs scheduler.getcurrentlyexecutingjobs(); , shut scheduler down if there aren't any?
yes. alternatively can call shutdown method , use overload allows specify whether wait until jobs finished
- does scheduler.getcurrentlyexecutingjobs(); return rejected/waiting jobs well?
no, executing ones. can list of scheduled jobs scheduler though calling getjobkeys , perhaps calling getjobdetail if needed.
- how start scheduler if it's down?
you can call start start scheduler, can't call if you've called shutdown, so, you'd have create new instance of scheduler , start it.
Comments
Post a Comment