Wednesday, March 4, 2009

Windsor facility for Quartz.NET

A few months ago I wrote a couple of adapters to integrate Quartz.Net into Windsor. These were loose components that you had to register yourself and the configuration wasn't very friendly. So I decided to wrap them in a facility to make things cleaner and easier.

This is what the facility provides:

Here's what it doesn't support:

  • These entities are NOT Windsor-managed (they are instantiated normally by Quartz instead)
  • Trigger and job group names

Note that it's up to you to register jobs with the appropriate lifestyle. Listeners can only have singleton lifestyle since they're injected in IScheduler which is itself a singleton.

Here are the bits:

22 comments:

wayne-o said...

Hi

This is very interesting as we've just gone from castle.scheduler to quartz and would ideally like to use your integration!

I would love to help out if i can but my inderstanding of the nuts and bolts of castle are v.limited.

give me a shout if i can help :)

Mauricio Scheffer said...

@wayne-o: great! We should move this discussion to the castle dev list. Create a new thread there and I'll get you up to speed.

wayne-o said...

FFR here is the link to that convo:
http://groups.google.com/group/castle-project-users/browse_thread/thread/1b5971028d05a2ab/9d2b197b9c20eb68?lnk=gst&q=QUARTZ#9d2b197b9c20eb68

Anonymous said...

Thanks this is really awesome! One question: how would I get a reference to the QuartzNetScheduler after it has been created through the windsor facility? I ask because I am using quartz from a windows service and I want to properly shut down the scheduler when the service is stopped.
Thanks

Mauricio Scheffer said...

@Anonymous: resolve Quartz.IScheduler from Windsor.

Ciprian said...

I'm using this facility in my project and I'd like to have the jobs 'Transient'. By default, it seems they are singletons.
Is there a way to define the job LifeStyle like this:
container.Register(Component.For().ImplementedBy().LifeStyle.Transient);

or similar?

Thank you!
Ciprian

Ciprian said...

Ok, I've just succeed:

container.Register(Component.For().Named("sampleJob").LifeStyle.Transient);

Thanks!
Ciprian

Davide Icardi said...

Do you have any plan for implementing the facility for Quartz 2.0?
Do you need help? I can fork the project on github?

Thanks

Mauricio Scheffer said...

@Davide: sure, go ahead and fork it.

Unknown said...

hey mauricio, do you have any plans of providing castle integration the latest build of quartz together?

We would like to use quartz 2.1.2 and castle 3.0.0.

Mauricio Scheffer said...

@Mihir : I upgraded the package to Castle 3.2 and Quartz 2.x about a month ago: http://nuget.org/packages/Quartz.Windsor/

Please use the issue tracker or the Castle mailing list for any other questions about this.

nub340 said...

@wayne-o: Thanks this looks awesome but unfortunately it's not working for me. I keep getting an error saying it could not load assembly Quartz, Version=2.2.400.0. However, when I look in my packages folder I see the version of Quartz nuGet actually downloaded is 2.2.2.4. I tried to download your source project so I could re-compile it with Quartz 2.2.2.4 version but all the references are duplicated/messed up. I tried resolving them but then I get a whole bunch of other errors. *sigh* Anyhow, I figured this might be something you could fix really fast before I went to crazy trying to fix it myself. Please let me know if I am doing anything wrong. Thanks again!

Mauricio Scheffer said...

@nub340 What specifically are you talking about? If there are issues with this Windsor facility please post them to https://github.com/castleprojectcontrib/QuartzNetIntegration/issues

nub340 said...

@wayne-o: Thanks for the quick response! Okay I created an issue on GitHub for this: https://github.com/castleprojectcontrib/QuartzNetIntegration/issues/13


Mauricio Scheffer said...

@nub240 Just to clear things up: I'm not wayne-o, my name is Mauricio Scheffer, I'm the author of the project and this post.

nub340 said...

I see sorry for the mix-up.

SpaceCowboy1974 said...

Mauricio, I downloaded your code from github and see how you implemented the various listeners in the SampleApp. You mentioned that the IJob interface was also Windsor managed as was IJobFactory. From what i saw in the sample app, the job you use was purely a Quartz implementation, not Windsor. Do you have a sample that injects the jobs via Windsor? Also, I assume i could set the jobs up in SQL using an ADOJobStore?

To give you some idea of what we are doing, we are creating a service that will execute many different jobs at different times, but we do not want to have to recompile every time we add a job.

I guess i am unclear on what would have to change to inject a job using Windsor both in the config and the quartz_jobs.xml?

Mauricio Scheffer said...

@SpaceCowboy1974 : all jobs are managed by Windsor. In the SampleApp, the SampleJob is resolved from Windsor whenever Quartz needs it, and therefore it can get injected as usual (either via constructor or setters).

And yes you should be able to use this with any job store.

Mauricio Scheffer said...

Please post any questions about this facility to https://groups.google.com/forum/#!forum/castle-users and any issues to https://github.com/castleprojectcontrib/QuartzNetIntegration/issues

Brooke said...

Hi Mauricio!

I've been using the castle quartz.net integration facility version 0.1.0.0 for a few years, and it's been working great!

I just upgraded to 0.3.2.0 b/c I upgraded Quartz, but I'm finding that the new implementation of IScheduler, QuartzNetScheduler, no longer includes the SetSchedulerListeners method, so my custom implementation of ISchedulerListener is not getting added to the SchedulerListeners. Is this just an oversight or is it intentional for some reason? Is there a plan to add it back?

Thanks!
~b

Mauricio Scheffer said...

Hi Brooke, can you post that to https://github.com/castleprojectcontrib/QuartzNetIntegration/issues ? Thanks

herbal erection pills said...

Hello, its fastidious paragraph concerning media print, we all understand media is a enormous source of information.