I am working with Quartz.Net.I succeeded to set up quartz_jobs.xml and to have the job run when the trigger is launch. However, at my first run, all my jobs are executed disregarding my schedule, then my schedule is apply. Do I have any properties, parameters in the quartz_jobs.xml or in the ISchedule schedule that I need to update in order that my jobs are run only on my Cron schedule, not also at the first run?
Job Runner file example:
public void Run()
{
Console.WriteLine("------- Initializing ----------------------");
// First we must get a reference to a scheduler
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "XmlConfiguredInstance";
// 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";
ISchedulerFactory sf = new StdSchedulerFactory(properties);
IScheduler sched = sf.GetScheduler();
// we need to add calendars manually, lets create a silly sample calendar
var dailyCalendar = new DailyCalendar("00:01", "23:59");
dailyCalendar.InvertTimeRange = true;
sched.AddCalendar("cal1", dailyCalendar, false, false);
Console.WriteLine("------- Initialization Complete -----------");
log.Info("------- Initialization Complete Email -----------");
// all jobs and triggers are now in scheduler
// Start up the scheduler (nothing can actually run until the scheduler has been started)
sched.Start();
Console.WriteLine("------- Started Scheduler with the following jobs -----------------");
// print jobs that are loaded into the scheduler
PrintAllJobs(sched);
Console.WriteLine("------- Waiting to see it run... (should see at least 2 runs in 5 min) -------------");
// wait long enough so that the scheduler as an opportunity to fire the triggers
try
{
Thread.Sleep(300 * 1000);
}
catch (ThreadInterruptedException) {}
// shut down the scheduler
Console.WriteLine("------- Shutting Down ---------------------");
sched.Shutdown(true);
Console.WriteLine("------- Shutdown Complete -----------------");
}
One my job example:
<!-- Get Email-->
<job>
<name>jobEmailFeed</name>
<group>jobGroup1</group>
<description>jobDesciption1</description>
<job-type>BigBrother.ScheduledJobs.EmailFeedJob, BigBrother</job-type> <!-- Path to first job-->
<durable>true</durable>
<recover>false</recover>
<job-data-map>
<entry>
<key>JobMapDataKey_ParamaterFile</key>
<value>Config\InputsRTD_EmailVol_Test.csv</value>
</entry>
</job-data-map>
</job>
<trigger>
<cron>
<name>EmailTrigger</name>
<job-name>jobEmailFeed</job-name>
<job-group>jobGroup1</job-group>
<start-time>1982-06-28T18:15:00.0Z</start-time>
<end-time>2020-05-04T18:13:51.0Z</end-time>
<misfire-instruction>SmartPolicy</misfire-instruction>
<cron-expression>0 0 11 ? * MON-FRI</cron-expression>
</cron>
</trigger>
No comments:
Post a Comment