Programming Keys is blog for all Programming and technology related articles

Showing posts with label #Quartz. Show all posts
Showing posts with label #Quartz. Show all posts

Monday, February 12, 2018

Quartz.NET 3.0.2 Configure AdoJobStore JobStore Sql server



Quartz.NET 3.0.2 Configure AdoJobStore JobStore SQL server


in the previous article, i have explained how to create jobs and triggers dynamically
this article will explain steps to configure quartz with SQL server

Step 1 : 

go to database\tables\tables_sqlServer.sql
and execute scripts in your SQL server DB you will see the list of tables 


Step 2 :

Open app.config and add quartz configuration settings


<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    </configSections>
  <quartz>
<add key="quartz.scheduler.instanceName" value="SchedulinginstanceName"/>
<add key="quartz.scheduler.instanceId" value="SchedulinginstanceId"/>


<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<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="true" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />

<add key="quartz.dataSource.default.connectionString" value="Server=yourhostname;Database=yourdatabasename;Trusted_Connection=True;"/>
<add key="quartz.dataSource.default.provider" value="SqlServer" />
<add key="quartz.serializer.type" value="json" />

</quartz>
</configuration>

Step 3 :

Install-Package Quartz.Serialization.Json -Version 3.0.0 


Step 4 : Create your scheduler in code

 var config = (NameValueCollection)ConfigurationManager.GetSection("quartz");
            return config;

ISchedulerFactory factory = new StdSchedulerFactory(config);
            scheduler = factory.GetScheduler().Result;
             scheduler.Start().Wait();

that's it you have successfully configured quartz with SQL server






Share: