Monday, June 21, 2010

Embeddable Quartz.Net web consoles

 

I wrote another embeddable web console (the third so far, the others being the NHibernate and the Boo console). This one is a manager for the Quartz.NET job scheduler.

Even though ASP.NET is not the perfect environment to run scheduled jobs, I do use Quartz.NET sometimes to schedule some non-critical maintenance jobs in web applications. And sometimes I need to pause or manually launch a job. So I went looking for a web interface and found two (quartznet-admin and Quartz.Web) but they're full ASP.NET MVC apps, not meant to be embeddable. So I built my own:

QuartzNetWebConsole

Project homepage
Downloads
Here are some screenshots showing its features, with a sample application:

Index / Dashboard:

qnindex

Triggers per group (the jobs per group page is very similar):

qntriggers

Scheduler log: 

qnlog

Log RSS:

qnrss

Setup:

  1. Reference QuartzNetWebConsole.dll in your application
  2. Add it to your httpHandlers in your web.config:
    <add verb="*" path="quartz/*" validate="false" type="QuartzNetWebConsole.ControllerFactory, QuartzNetWebConsole"/> 
  3. Configure it with QuartzNetWebConsole.Setup in your Application_Start(), e.g:
    protected void Application_Start(object sender, EventArgs e) {
    	Quartz.IScheduler scheduler = BuildQuartzScheduler();
    	QuartzNetWebConsole.Setup.Scheduler = () => scheduler;
    	...
    }
  4. Optionally, add a logger (any class implementing QuartzNetWebConsole.ILogger). An in-memory logger is provided:
    var partialQuartzConsoleUrl = string.Format("http://{0}:{1}/quartz/", Context.Request.Url.Host, Context.Request.Url.Port); // quartz web console url, required for RSS
    QuartzNetWebConsole.Setup.Logger = new QuartzNetWebConsole.MemoryLogger(1000, partialQuartzConsoleUrl); // stores 1000 log entries

As usual, it's up to you to secure it as you see fit.

Crystal Quartz

After I wrote this whole thing, I found another open source project (written a couple of months ago, it seems) that does about 80% of I needed! Apparently my google-fu failed me. Anyway, this project is called Crystal Quartz and was created by Guryanov Evgeniy. As far as I know, it hasn't been released and nobody has blogged about it, in fact the only reference I found was this message. I got the source code and gave it a try, and it looks good. Here are the screenshots:

Index:

cqindex

Job detail:

qcjob

Conclusions

So there you go, now you have two embeddable web managers for Quartz.NET to choose from.
One of the cool things about Quartz.NET is that it's easily remotable, so you can also use these managers with a Quartz.NET Windows Service, just by telling the web IScheduler to connect to a remote scheduler instance.

15 comments:

  1. Thanks for this app. I've added it to my application and am testing it out. To the setup steps, could you please add that you need to ignore the quartz route like so:

    routes.IgnoreRoute("quartz/{*pathInfo}");

    ReplyDelete
  2. Hey Thanks, Your site has been a lot of help setting up quartz!

    ReplyDelete
  3. I recently came across your quart.net embedded web console. decided to give it a try with a quartz.net web services.

    resolved some issues with conflicting dll with current version of quart.net dll (it's now at 2.2.1, so need to force uninstall and install the 2.2.0 version). Everything else is fine.

    But visits to quartz/index.html results in the following exception from quartzwebconsole:

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    Operation not supported for remote schedulers.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Quartz.SchedulerException: Operation not supported for remote schedulers.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [SchedulerException: Operation not supported for remote schedulers.]
    Quartz.Impl.RemoteScheduler.get_ListenerManager() +46
    QuartzNetWebConsole.Utils.SchedulerWrapper.get_ListenerManager() +13
    QuartzNetWebConsole.Controllers.IndexController.Execute(HttpContextBase context, Func`1 getScheduler) +250
    QuartzNetWebConsole.ControllerFactory.<.ctor>b__6(HttpContextBase ctx) +47
    MiniMVC.HttpHandler.ProcessRequest(HttpContext context) +45
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

    ReplyDelete
  4. dev@spd : please open a new issue in https://github.com/mausch/QuartzNetWebConsole/issues

    ReplyDelete
  5. Posted an issue as you requested.

    ReplyDelete
  6. Thanks for your application. It is goode. But we need more for our application like crystal-quartz. Can you please tell how to implement crystal-quartz in asp.net application or provide any link which describes the procedure. Thanks in advance.

    ReplyDelete
  7. Thanks for this app. It is good to organize quartz Jobs.
    I have one doubt in this. Is there any way to show the logger time in EST?

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete
  10. For the QuartzNetWebConsole, what url do I go to to see the console?

    ReplyDelete
  11. @Matt: for the config mentioned here it'd be /quartz/index.ashx

    ReplyDelete
  12. Thanks for the quick reply. I am curious, where would I have found that out? Is it documented?

    ReplyDelete
  13. Having a hard time setting up the Owin implementation, I copied the exact sample and was unable to get it run. Is there anything else missing?

    ReplyDelete
  14. Hi Eddie, please post that with details to https://github.com/mausch/QuartzNetWebConsole/issues

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete