Is quartz job storage associated with active data?

As I understood from the official Quartz documentation , AdoStore should be used for active storage of data, such as JobDataMap and other data. Correct me if I am wrong.

Besides this explanation, I would like to know if there is a way to load the task and initiate the definition from the database. The view of the plugin or something like Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin designed to be read from an XML file.

If this is not the case, is this the best solution for implementing a custom plugin that will be read from the database or use some other approach?

[EDIT] Rastko on 8/13/2012 11:16:28 AM

From the answers below, I think I did not describe the problem to you well. I would like to download the task and do the setup from the database. As defined in code or in xml, like this:

  <job> <name>WriterJob</name> <group>CommonGroup</group> <description>Test WriteJob</description> <job-type>Console.WriteJob, Console</job-type> </job> <trigger> <simple> <name>WriterJobTrigger</name> <group>CommonTriggerGroup</group> <description>Simple trigger to simply fire sample job</description> <job-name>WriterJob</job-name> <job-group>CommonGroup</job-group> <misfire-instruction>SmartPolicy</misfire-instruction> <repeat-count>-1</repeat-count> <repeat-interval>10000</repeat-interval> </simple> </trigger> 

I want to have this also in DataBase. From the created tables for ADOJobStore, I see that these tables are more related for tracking current active tasks - tracking status, trigger operation, etc.

Hopefully now I will be more clear. Feel free to ask me if you need further clarification.

+4
source share
3 answers

I would like to know if there is a way to load the task and initiate the definition from the database.

If you want to get a list of tasks from the database, you can do something like:

  Quartz.IScheduler scheduler ; .... var details = (from groupName in scheduler.GetJobGroupNames() from jobKey in scheduler.GetJobKeys( Quartz.Impl.Matchers.GroupMatcher<Quartz.JobKey> .GroupEquals(groupName)) select new { GroupName = groupName, JobName = jobKey.Name , triggers = scheduler.GetTriggersOfJob(jobKey) } ); 

This syntax is for Quartz 2.0.

If you create a separate program from a program that actually performs tasks, then you simply create a scheduler with the same details, but do not call scheduler.Start ()

If you want to add new tasks to your database, you can do something like:

(where SimpleJob is the C # class name of your job)

 string jobName = ... string triggerName = ... string cronExpression = ... Quartz.IScheduler scheduler = ... Quartz.IJobDetail jobDetail = Quartz.JobBuilder.Create<SimpleJob>() .WithIdentity(jobName) .StoreDurably() .Build(); Quartz.ITrigger trigger = Quartz.TriggerBuilder.Create() .WithIdentity(triggerName) .WithSchedule(Quartz.CronScheduleBuilder.CronSchedule(cronExpression) .ForJob(jobName) .Build(); scheduler.ScheduleJob(jobDetail, trigger); 

If you want to add a task to the database without connecting a trigger

 Quartz.IJobDetail jobDetail = Quartz.JobBuilder.Create<SimpleJob>() .WithIdentity(jobName) .StoreDurably() .Build(); scheduler.AddJob(jobDetail, false) 

If you plan to complete a one-time existing task, then

  Quartz.ITrigger trigger1 = Quartz.TriggerBuilder.Create() .WithIdentity(triggerName) .WithSchedule(Quartz.SimpleScheduleBuilder.Create()) .ForJob(jobName) .Build(); scheduler.ScheduleJob(trigger1); 
+11
source

I use Quartz for java, but since the main logic is the same, I can say that using XML for task schedulers is not a good idea. Each time you change the status of a job, you will need to change the xml file. Using databases (AdoJobStore in your case) may be more efficient.

0
source

take a look at the implementation of XMLSchedulingDataProcessorPlugin. basically you need to implement ISchedulerPlugin and add logic to load tasks.

0
source

All Articles