3

I am a total noob to Quartz.net and writing windows services, so I apologize if this question is a bit uninformed.

Anyway, I set up a windows service to use quartz.net to run another windows service which does some file cleanup. It installs and runs just fine (at least according to installutil and the net start command), but it never adds anything to the database.

I created the db tables and everything and the db itself looks fine. Then, I created an app.config, which contains (i think) all of the config settings i need to be using to hook this thing up to the db. But for some reason, the db never gets touched. No triggers created (i obviously created them in code), no queued jobs, nothing.

It is an oracle db, and all of the permissions are set up to allow read/write and everything.

Here is the source code for the app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>

<quartz>

<add key="quartz.scheduler.instanceName" value="TestQuartzServer" />
<add key="quartz.scheduler.instanceId" value="instance_one" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="Normal" />
<add key="quartz.jobStore.misfireThreshold" value="60000" />
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
<add key="quartz.jobStore.useProperties" value="false" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
<add key="quartz.jobStore.clustered" value="true" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.SimpleSemaphore, Quartz" />
<add key="quartz.dataSource.default.connectionStringName" value="ConnectionString" />
<add key="quartz.dataSource.default.provider" value="OracleClient-20" />
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.StdAdoDelegate, Quartz" />
</quartz>
 <connectionStrings>
    <add name="ConnectionString" connectionString= "Server=localhost;Database=Quartz;Uid=Quartz;Pwd=Quartz" />
</connectionStrings>
</configuration>

And here is the app source:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using Quartz;
using Quartz.Impl;
using Quartz.Impl.Triggers;
using System.Collections;

namespace PurgeScheduler1
{

    public partial class Service1 : ServiceBase
    {
        public static IScheduler _scheduler;
        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            try {
            ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
            _scheduler = schedulerFactory.GetScheduler();
            _scheduler.Start();
            AddJob();
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }


        protected override void OnStop()
        {
        }

        public static void AddJob()
        {
            IJob myJob = new MyJob();
            JobDetailImpl jobDetail = new JobDetailImpl("Purge", "Group1", myJob.GetType());
            CronTriggerImpl trigger = new CronTriggerImpl("Trigger1", "Group1", "When to run it goes here");
            SimpleTriggerImpl trigger1 = new SimpleTriggerImpl("Trigger2", 10, TimeSpan.FromMinutes(2));
            _scheduler.ScheduleJob(jobDetail, trigger1);
            DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
            Console.WriteLine("Next Fire Time:" + nextFireTime.Value);
        }
    }
    internal class MyJob : IJob
    {
        public void Execute(IJobExecutionContext context)
        {
            Console.WriteLine("In myJob class");
            Process.Start("correct path, but hiding it for proprietary reasons");
        }
    }
}
Phillip Schmidt
  • 8,805
  • 3
  • 43
  • 67
  • have you tried it with: quartz.dataSource.default.connectionString ? – Leblanc Meneses Jun 05 '12 at 03:32
  • @LeblancMeneses yeah, sorry, I tried it. Didn't work. And it's actually a requirement that I use a windows service, so that part won't work either – Phillip Schmidt Jun 05 '12 at 15:27
  • topshelf is a better way to build window services http://topshelf-project.com/documentation/command-line-syntax/ and is how quartz default service is built. Without running the code locally I'm out of ideas if it is not quartz.dataSource.default.connectionString . Good luck! – Leblanc Meneses Jun 06 '12 at 03:34

2 Answers2

2

quartz.dataSource.default.connectionStringName

The above should be: quartz.dataSource.default.connectionString

Please try with 'quartz.jobStore.clustered' set to false. To narrow down potential problems.

You should not need installutil anymore. quartz provides a server implementation already for you out of the box that uses topshelf. Topshelf replaces you having to create a windowservice project that inherits from ServiceBase. you can install the default service using: Quartz.Server.exe /install but would recommend using the visual studio debugger - since it is a console app for you to debug the problem.

https://github.com/quartznet/quartznet See: Quartz.Server.2010.sln

Just needs the configuration to be specified.

Leblanc Meneses
  • 3,001
  • 1
  • 23
  • 26
1

You must add the handeler in the configSections of your app.config:

<configSections>
     <section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>

You can configure a logger to do some debugging. I use NLog. You can find an implementation here.

Community
  • 1
  • 1
LeftyX
  • 35,328
  • 21
  • 132
  • 193
  • sorry, that was actually in there -- it just didn't roll over when i c&p'd the source code. I've edited the question to show that it is in there. Do you have any other ideas? – Phillip Schmidt May 29 '12 at 14:06