Friday, December 2, 2011

Installing Quart.Net 2.0 Beta 1 as a Windows Service

NOTE: I'm now blogging at http://jayvilalta.com/blog and not updating this blog anymore. For information on the latest version of Quartz.Net, visit me there.

Now that there is an official beta release of Quartz.Net 2, I thought it would be a good idea to go through the installation process and describe it step by step. Before we get started I’d like to point out that this post was written using Windows 7, so the screenshots may not match exactly what you see if you are on a different version.

Step 1: Download and Unpack the Binaries

The latest Quartz.Net 2.0 binaries are available from Sourceforge, here. Download the zip file and unpack the contents to a folder. If you are using Windows 7, be sure to unblock the downloaded zip file before extracting the files. This is done by right clicking on the downloaded file and clicking on the unblock button BEFORE unzipping the file.
image
I will be unzipping the file to c:\quartznet2 for this article. Once you’ve downloaded and unpacked the files, you should have the following directory structure:
image

Step 2: Select the Appropriate Version

The beta 1 distribution provides binaries for the 3.5 and 4.0 versions of the .Net framework. Select the appropriate folder for your version from the following:
image

Step 3: Sanity Check

Before installing Quartz.Net 2 as a service, let’s check that everything is working properly. I’m running version 4.0 of the framework so I will open a command prompt as Administrator in the 4.0 folder. Note: If you don’t open the command prompt as administrator, you will get no error messages or UAC prompts. The installation will simply fail.
image
Now that we have a command prompt, let’s try starting the Quartz.Net server. To do this, simply run Quartz.Server.exe by typing it into the command prompt.
If nothing happens, then you probably forgot to unblock the files you downloaded. Go back to Step 1 and start over. If everything is well, you will see some output in the command prompt. This means Quartz.Net is running and that the sample job that is configured out of the box is running correctly.
image
You may also get a firewall warning window, similar to this one:
image
This is because by default the scheduler exposes a remoting interface that allows you to interact with it. If you wish to enable access to remoting, then go ahead and click allow access. otherwise, click cancel. You’ll have to configure the firewall manually later if you wish to enable remoting access on the scheduler.
Press CTRL-C to stop the scheduler.

Step 4: Installing the Service

At this point you should be quite confident that the base distribution will work once installed as a windows service. Now it’s time to install the service. To do this, type Quartz.Server.exe install in the command prompt. If all goes well, you should see the following in your command prompt.
image
Now type services.msc in the command prompt to open the services administration window. There you should see the quartz service installed as “Quartz Server” with automatic startup and running under the Local System account. 
image
You should now be able to start and stop the service through the administration window.

11 comments:

Anonymous said...

Thx, works fine!

djbuijs said...

Thanks, your blogs helped me a lot in getting started with Quartz.

J said...

Thanks for the feedback!

Anonymous said...

Finally ditching Windows Task Scheduler in favour of Quartz. Thanks for this great article.

J said...

Thanks for the feedback. Much appreciated!

OZ said...

Thanks for this tutorial, installation ok for me but...
This is no tutorial for accessing this server !
How do we get the instance of this scheduler ?

J said...

@Oz, how you get a reference to the scheduler depends on whether it is running embedded inside your application or as a windows service. Which one is your case?

Bill Miller said...

Looking through the documentation and blog I'm looking for some guidance as to the best approach. I have a number of tasks/jobs that I would like to schedule. I would like to basically create these tasks as individual assemblies and then schedule them without modifying the quartz service bits. That way all I have to do is create new assemblies and add them to the xml.

I've not seen any clear documentation on this. Although I did see mention in a post on your blog the assemblies need to be in the same location as the service.

Possible to point me to the right resource?

J said...

Bill,

You're on the right path. Put your jobs in their own assemblies and then just copy your assemblies into the Quartz.net directory. Then configure the quartz_jobs.xml file to load the jobs or load them using the remoting reafture. That's all you need to do.
I haven't seen any documentation specifically around deployment, but you could check out the tutorial (beware it uses the 1.0 api but the overall way of working with Quarz.net hasn't changed) http://quartznet.sourceforge.net/tutorial/index.html

Alternatively, send a message to the Quartz.net group mailing list. I'm sure you'll get more deployment stories there.

josh said...

I installed Quartz scheduler as a windows servie. How do we get the instance of this scheduler(windows service)?

J said...

You can access the scheduler using the remoting feature or, if you want access to it while running a job for example, you can access it via the context that is passed in to the job.