Is new job and trigger in quartz update all triggers in database by default?
Is new job and trigger in quartz update all triggers by default?
My code with its app.config updates the database. But whenever I run it again, it goes and update all triggers and I don’t want this to happen.
Is this the default behavior? How can I stop this default?
Can someone help please?
Is overwrite-existing-jobs a solution to my question? How can I use it inside my code.
My new job and trigger is updating all the triggers in the QRTZ_TRIGGERS. I only need to update the job and trigger that is referencing inside my code and not the job and trigger inside the database.
For instance my current job is Job0c93eeab-f888-44c0-aef0-0eeafc4257fe and my current trigger is Trigger0c93eeab-f888-44c0-aef0-0eeafc4257fe , but my following code update all triggers in the database like the following:
NEXT_FIRE_TIME PREV_FIRE_TIME START_TIME
Job0c93eeab-f888-44c0-aef0-0eeafc4257fe group2 NULL 634976768200000000 634976768000000000 5 WAITING CRON 634976760920000000
Job2bdc4e09-b02c-4a5f-bfb4-233220fa5d68 group2 NULL 634976768200000000 634976768000000000 5 WAITING CRON 634976765110000000
public virtual void Run()
{
ILog log = LogManager.GetLogger(typeof(RunJob));
// First we must get a reference to a scheduler
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sched = sf.GetScheduler();
ExecuteJob.ClntID = ClntID;
Testingcounter = System.Guid.NewGuid().ToString();
Testingjob = "Job" + Testingcounter.ToString();
IJobDetail job = JobBuilder.Create<ExecuteJob>()
.WithIdentity(Testingjob, "group2")
.Build();
Testingtrigger = "Trigger" + Testingcounter.ToString();
ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create()
.WithIdentity(Testingtrigger, "group2")
.WithCronSchedule("0/20 * 10-23 * * ?")
.ForJob(job)
.Build();
DateTimeOffset ft = sched.ScheduleJob(job, trigger);
log.Info(job.Key + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.CronExpressionString);
sched.Start();
try
{
// wait five minutes to show jobs
Thread.Sleep(300 * 1000);
}
catch (ThreadInterruptedException)
{
}
sched.Shutdown(true);
SchedulerMetaData metaData = sched.GetMetaData();
log.Info(string.Format("Executed {0} jobs.", metaData.NumberOfJobsExecuted));
}
public virtual void Execute(IJobExecutionContext context)
{
string str = “My execute is running”;
}
This my app.config;
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<quartz>
<add key="quartz.scheduler.instanceName" value="TestQuartzServer" />
<add key="quartz.scheduler.instanceId" value="instance_one" />
<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="false" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
<add key="quartz.jobStore.clustered" value="true" />
<add key="quartz.jobStore.overwriteExistingJobs" value="false" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.SimpleSemaphore, Quartz" />
<add key="quartz.dataSource.default.connectionStringName" value="ConnectionStringName" />
<add key="quartz.dataSource.default.provider" value="SqlServer-20" />
</quartz>
<connectionStrings>
<add name="ConnectionStringName" connectionString="Data Source=MYDEVELOPMENTSQL;Initial Catalog=Quartz;Integrated Security=True" providerName="System.Data.SqlClient" />
</configuration>