Search code examples
c#.net-4.5quartz-schedulerquartz.netquartz

How to run/trigger old schdeuled jobs on windows service start in AdoJobStore


I have a system where i am scheduling some job and trigger to run at some specific time in a windows service . As my windows service can be restarted for number o0f reason I wanted to trigger the already schedule jobs at the time they were schedule so i am using AdoJobStore as it persist the job/trigger information. I were thinking at the time of start of the scheduler it will load the non completed job and fire it. But it can't I have configured a Adojobstore with following setting

 <add key="quartz.scheduler.instanceName" value="DBScheduler" />
    <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
    <add key="quartz.threadPool.threadCount" value="100" />
    <add key="quartz.threadPool.threadPriority" value="2" />
    <add key="quartz.scheduler.dbFailureRetryInterval" value="6000000000" />
    <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" />
    <add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
    <add key="quartz.jobStore.misfireThreshold" value="600000" />
    <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
    <add key="quartz.jobStore.dataSource" value="myDS" />
    <add key="quartz.dataSource.myDS.connectionString" value="Server=localhost;Port=3306;database=quartznet;Uid=root;pwd=root;allow user variables=true;CharSet=utf8;" />
    <add key="quartz.dataSource.myDS.provider" value="MySql" />
    <add key="quartz.serializer.type" value="binary" />

And Code for schdeuling start looks like following at my windows start class

  StdSchedulerFactory factory = new StdSchedulerFactory();

                MyQuartzScheduler = await factory.GetScheduler();
                await MyQuartzScheduler.Start();

What i thought a future job which i have schedules and who's entries are saved in quartznet db will trigger at there time after starting the schedule but it didn't. Is there any other settings or code i required to add?


Solution

  • Looks Like Problem was due to one configuration settings

    It appears following configuration setting was the culprit

    <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" />
    

    Changed it to

    <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.StdAdoDelegate, Quartz" />
    

    And it started working. Can some quartz.net experience person confirm the mistake