Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement Quartz in ServiceStack [closed]

I have looked around and haven't found a solid, up to date reference on using Quartz (or any comparable job scheduler) with ServiceStack. I would like to do the following:

  • Run Quartz or comparable scheduler as a service (to avoid IIS issues)
  • Our project uses ServiceStack, so I would like to use it to have familiar patterns for IoC, etc.

Does it make sense to use ServiceStack in a Windows service with a scheduler in this way? Is there a better arrangement? If it works, how do I run Quartz in ServiceStack?

I have lots of partial ideas in my head, but need help putting together a cohesive plan, so any help is much appreciated.

like image 616
TortillaCurtain Avatar asked Nov 13 '15 19:11

TortillaCurtain


3 Answers

You can use the ServiceStack.Quartz kindly made by wwwlicious.

like image 122
labilbe Avatar answered Oct 22 '22 01:10

labilbe


A great job scheduler is Hangfire (Hangfire.io). Personally like it a lot more than Quartz.

It is not as easy injecting Hangfire using existing IoC Funq container that comes with servicestack. But have a look at this question & answer

like image 35
Walter Avatar answered Oct 22 '22 01:10

Walter


I'm a bit late to the party here, but I'm in the same situation. I can't think of a good reason why implementing a Quartz Scheduler in a Self Hosted ServiceStack application would be a bad idea.

I quickly made a library that integrates the Quartz Scheduler with the ServiceStack Funq IoC which basically allows you to set up your Quartz with ServiceStack with:

//// This method scans the assembly for the Jobs
container.RegisterQuartzScheduler(typeof(HelloJob));

//// Resolve the Quartz Scheduler as normal
var scheduler = container.Resolve<IScheduler>();

//// Start Quartz Scheduler
scheduler.Start();

You will be able to use the Quartz Scheduler as you would normally.

I've provided an example of how it could be used here: https://github.com/CodeRevver/ServiceStackWithQuartz

NuGet is here: https://www.nuget.org/packages/ServiceStack.Funq.Quartz/

As I said, I did this in a few hours to see if it would fit my purposes. If you want to modify it to do something you want it to do, feel free to modify it.

If you're interested, I'm about to write a Blog post about it here: http://michaelclark.tech/2016/04/16/creating-a-servicestack-windows-service-that-uses-quartz/

like image 28
Michael Clark Avatar answered Oct 22 '22 00:10

Michael Clark