RAMJobStore (quartz_jobs.xml) for moving AdoJobStore data

My team and I are trying to find a way to "download" our Sql Server database with the Quartz.NET schema installed.

<add key="quartz.dataSource.default.provider" value="SqlServer-20"/>

For demonstration, we save our job settings in .xml (quartz_jobs.xml).

My question is:

Is there a way to “load” planning data from .xml (quartz_jobs.xml) (Quartz.Simpl.RAMJobStore) and then “save it” to AdoJobStore (Quartz.Impl.AdoJobStore.JobStoreTX)

The reason is that our “start-up” data can be easily written to an XML file.

Right now, the only way I see job placement in AdoJobStore is to “encode” them in C # code through the Quartz.Net object model.

Or "playback" of some TSQL profiled (using Sql Profiler): (

The direct question above is "(getting xml in sql-server)" ..... a higher level question: "How to populate an AdoJobStore using data launch ... it's not" encoding "in C # code.

EDIT: I embed my code that works ... using Marco's answer (accepted as the answer).

My configuration file:

<quartz>

    <add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz" />
    <add key="quartz.plugin.xml.fileNames" value="~/Quartz_Jobs_001.xml" />
    <add key="quartz.plugin.xml.ScanInterval" value="10" />

    <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
    <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz"/>
    <add key="quartz.jobStore.dataSource" value="default"/>
    <add key="quartz.dataSource.default.connectionString" value="Server=MyServer\MyInstance;Database=QuartzDB;Trusted_Connection=True;Application Name='quartz_config';"/>
    <add key="quartz.dataSource.default.provider" value="SqlServer-20"/>

</quartz>

My code is:

    NameValueCollection config = (NameValueCollection)ConfigurationManager.GetSection("quartz");
    ISchedulerFactory factory = new StdSchedulerFactory(config);
    IScheduler sched = factory.GetScheduler();
    sched.Clear();
    sched.Start();

Note:

I needed to call IScheduler.Start () to store the values ​​in the database.

The consequence of adding this line:

 <add key="quartz.plugin.xml.ScanInterval" value="10" />

it was that I could add entries to the quartz_job.xml file, and it could (add only) the data in the database (while the engine was running).

Aka, I can "add search data" (to the database) "on the fly" .... without stopping the service. Nice little tidbit. To delete a job, a reboot is required.

+1
1

. XML ADO. XML- .

:

NameValueCollection properties = new NameValueCollection();

properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz";

properties["quartz.dataSource.default.connectionString"] = "Server=(local);Database=quartz;Trusted_Connection=True;";
properties["quartz.dataSource.default.provider"] = "SqlServer-20";

// job initialization plugin handles our xml reading, without it defaults are used
properties["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz";
properties["quartz.plugin.xml.fileNames"] = "~/quartz_jobs.xml";

// First we must get a reference to a scheduler
ISchedulerFactory sf = new StdSchedulerFactory(properties);
IScheduler sched = sf.GetScheduler();

XML , :

<?xml version="1.0" encoding="UTF-8"?>

<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                version="2.0">

  <processing-directives>
    <overwrite-existing-data>true</overwrite-existing-data>
  </processing-directives>

  <schedule>

    <job>
      <name>jobName1</name>
      <group>jobGroup1</group>
      <description>jobDesciption1</description>
      <job-type>Quartz.Examples.Example15.SimpleJob, Quartz.Examples</job-type>
      <durable>true</durable>
      <recover>false</recover>
    </job>

    <trigger>
      <simple>
        <name>simpleName</name>
        <group>simpleGroup</group>
        <description>SimpleTriggerDescription</description>
        <job-name>jobName1</job-name>
        <job-group>jobGroup1</job-group>
        <start-time>1982-06-28T18:15:00.0Z</start-time>
        <repeat-count>-1</repeat-count>
        <repeat-interval>3000</repeat-interval>
      </simple>
    </trigger>

  </schedule>

</job-scheduling-data>

XML ( 10 ), :

properties["quartz.plugin.xml.ScanInterval"] = "10";
+3

Source: https://habr.com/ru/post/1545323/


All Articles