3

I currently have a UI in MVC 3 that allows users and admins to configure and create Jobs, Tasks, and specific configuration values into the application. I want to implement Quartz.Net to use for scheduling, launching, and logging job execution. I was looking for some help in configuring the MVC 3 app to use quartz. Where should I put the Quartz.Net config values? Web.Config? Or separate Quartz.Config file? I plan to use the AdoJobStor. Do I have to implement a Singleton class for using the Quartz.Net Scheduler in various areas of my MVC 3 app?

Thanks for the help.....

M4V3R1CK
  • 765
  • 3
  • 9
  • 22

2 Answers2

6

I would not put a scheduler on a IIS-hosted application as it will eventually recycle.

This will cause the scheduler to stop until the IIS process is recreated when the website gets hit by requests. This may sound OK for high-activity websites but remember IIS may decide to recycle your scheduler at unexpected times (like in the middle of executing a task). You should move the scheduler part to a Windows Service.

Edit: http://hangfire.io/ seems like a nice way to run scheduled tasks in ASP.Net

Edit2: I'm actually using HangFire in a project. It is very easy to use and powerful.

Fabian Nicollier
  • 2,811
  • 1
  • 23
  • 19
  • Could you please point me out to documentation/help/tutorial/sample for Hangfire (.Net 4.0) – bjan Dec 05 '15 at 19:31
  • I think these are for 1.5 which supports .Net 4.5 and does not work for .Net 4.0. Mainly i was not able to find `GlobalConfiguration.Configuration` – bjan Dec 07 '15 at 05:57
6

I would start with the tutorial.
There's pretty much everything you need to know to start with it.
You can configure quartz.net via config file or programmatically, as explained here.
Loads of useful information here in S.O.:

Configuring ADOJobStore with Quartz.net. Some more infos here and here.

Configuring logging.

If you want to use Quartz.net in you asp.net you have to use singleton schedulers.

Community
  • 1
  • 1
LeftyX
  • 35,328
  • 21
  • 132
  • 193
  • I got Quartz.Net all configured but I am a little confused about how to go about allowing it be used centrally from potentially many clients. I basically want to ensure that jobs executed in a timely manner without hampering the performance of my Web App. to – M4V3R1CK Jul 07 '11 at 18:28
  • @M4V3R1CK: In one of my projects I've created a the web app (asp.net MVC) which is responsible to create jobs and schedules and then I've chosen to create a custom Windows Services for the schedules.I haven't used Quartz.net service but I've decided to build one from scratch. – LeftyX Jul 08 '11 at 07:44
  • @LeftyX, I do working on similar requirement asked by M4V3R1CK. Due to IIS recycle problem, the quartz.net scheduler is stopped working :( Do you have any solution for it? Also can you provide some more implementation details, how can we go with a separate service for schedule and use Quartz.net for jobs in asp.net? Any articles? I am using ASP.Net MVC4 – Billa Jun 20 '14 at 10:24
  • 1
    @Billa, what you can do is run your quartz.net scheduler in a windows service. Your asp.net MVC App will basically create jobs and triggers which will be processed by the service. You have to use ADOJobStore. I'll try to update my answer with some code. – LeftyX Jun 20 '14 at 11:18
  • @LeftyX. Thank you so much!!. So all the trigger information will be stored in database and a Window service will run based on it? But I hosted my application in external Hosting server. I don't think I can run quartz windows service in their machine :( – Billa Jun 20 '14 at 11:25
  • @Billa, that's right. Your web app and the windows service share the same database. I guess if you cannot install the windows service there's not much you can do. You can try and keep your web app awake but it's not really reliable. – LeftyX Jun 20 '14 at 11:57
  • @LeftyX, Yes, Finally i am trying to use Application_End method as i explained in this question http://stackoverflow.com/questions/24326172/detect-site-login-url-in-application-end – Billa Jun 20 '14 at 12:08