quartz.net - RAMJobStore (quartz_jobs.xml) to AdoJobStore Data Move -


my team , trying figure out way "load up" our sql server database quartz.net schema installed.

<add key="quartz.datasource.default.provider" value="sqlserver-20"/> 

for demo's, we've been storing our job-setups in .xml (quartz_jobs.xml).

my question :

is there way "load up" scheduling data .xml (quartz_jobs.xml) (quartz.simpl.ramjobstore), , "save off" adojobstore (quartz.impl.adojobstore.jobstoretx) ?

the reason our "start up" data written placed in .xml.

right now, way see putting jobs adojobstore "coding them up" in c# code through quartz.net object model.

or "playing back" profiled tsql (using sql profiler) :(

direct question above "(getting xml sql-server)".....the higher level question "how 1 populate adojobstore start data...that isn't "coding them up" in c# code.

edit: i'm putting in code works......using marko's (accepted answer) response.

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:

    namevaluecollection config = (namevaluecollection)configurationmanager.getsection("quartz");     ischedulerfactory factory = new stdschedulerfactory(config);     ischeduler sched = factory.getscheduler();     sched.clear();     sched.start(); 

note:

i had call ischeduler.start() values persist database.

the consequence of adding line:

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

was add entries quartz_job.xml, , would (append-only) data in database (while engine running).

aka, can "add lookup data" (to database) "on fly"....without stopping service. nice little tidbit. removing job requires restart.

you should able quite easily. can combine xml configuration , ado job store. make xml processor update jobs in persistent store.

here's minimal configuration:

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 defaults used properties["quartz.plugin.xml.type"] = "quartz.plugin.xml.xmlschedulingdataprocessorplugin, quartz"; properties["quartz.plugin.xml.filenames"] = "~/quartz_jobs.xml";  // first must reference scheduler ischedulerfactory sf = new stdschedulerfactory(properties); ischeduler sched = sf.getscheduler(); 

and our xml configuration contains overwrite instructions job store refreshed:

<?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> 

you can make xml auto refresh store on change (checked every 10 seconds) if define:

properties["quartz.plugin.xml.scaninterval"] = "10"; 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -