Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can quartz.net reconfigure jobs when config file changes?

Tags:

quartz.net

Im doing a proof of concept with Quartz.Net A fairly simple scheduling task, the only requirement i have is that a restart of the service it not needed to reconfigure quartz

This is test code

        var factory = new StdSchedulerFactory();
        var scheduler = factory.GetScheduler();
        scheduler.Start();

Relevant data in app.config

  <quartz>
<add key="quartz.scheduler.instanceName" value="QuartzScheduler" />
<!-- Configure Thread Pool -->
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="Normal" />
<!-- Configure Job Store -->
<add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz" />
<add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.JobInitializationPlugin, Quartz" />
<add key="quartz.plugin.xml.fileNames" value="quartz.config" />

My job config file

    <?xml version="1.0" encoding="UTF-8"?>
<quartz xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                version="1.0"
                overwrite-existing-jobs="true">

  <job>
    <job-detail>
      <name>jobName1</name>
      <group>jobGroup1</group>
      <description>jobDesciption1</description>
      <job-type>Jobs.MyJob, Jobs</job-type>
      <volatile>false</volatile>
      <durable>true</durable>
      <recover>false</recover>
    </job-detail>

    <trigger>
      <cron>
        <name>cronName1</name>
        <group>cronGroup1</group>
        <description>CronTriggerDescription</description>
        <job-name>jobName1</job-name>
        <job-group>jobGroup1</job-group>
        <cron-expression>0 0/1 * * * ?</cron-expression>
      </cron>

    </trigger>
  </job>
</quartz>

The cron expression works and teh job is executed each minute, but if i change the expression to 0 0/5 * * * ? while running the service it still fires each minute. So is there a way to config Quartz.net so that it listens to file changes to the config file?

like image 850
Anders Avatar asked Feb 01 '11 16:02

Anders


People also ask

How does Quartz. net work?

As per their website: Quartz.NET is a full-featured, open source job scheduling system that can be used from smallest apps to large scale enterprise systems. It's an old staple of many ASP.NET developers, used as a way of running background tasks on a timer, in a reliable, clustered, way.

How many jobs can Quartz handle?

The actual number of jobs that can be running at any moment in time is limited by the size of the thread pool. If there are five threads in the pool, no more than five jobs can run at a time.

How do you pass parameters to Quartz job?

Start up the Quartz Scheduler. Schedule two jobs, each job will execute the every ten seconds for a total of times. The scheduler will pass a run-time job parameter of “Green” to the first job instance. The scheduler will pass a run-time job parameter of “Red” to the second job instance.

How do I interrupt a Quartz job?

scheduler. deleteJob(jobKey(<JobKey>, <JobGroup>)); This method will only interrupt/stop the job uniquely identified by the Job Key and Group within the scheduler which may have many other jobs running.


1 Answers

Add scan interval definition (seconds) for the plugin:

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

After that plugin will periodically check for file changes.

like image 66
Marko Lahma Avatar answered Sep 22 '22 19:09

Marko Lahma