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:

John Doe said...

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}");

MvcCmsJon said...

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

dev@spd said...

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

Mauricio Scheffer said...

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

dev@spd said...

Posted an issue as you requested.

Gopikrishna said...

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.

Anonymous said...

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?

Digitalbit said...
This comment has been removed by a blog administrator.
Unknown said...
This comment has been removed by a blog administrator.
Matt's New Blog said...

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

Mauricio Scheffer said...

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

Matt's New Blog said...

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

Unknown said...

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?

Mauricio Scheffer said...

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

George Morgan said...
This comment has been removed by the author.