石英工作专卖店是关系到活动的数据? [英] Quartz job store is related to active data?

查看:104
本文介绍了石英工作专卖店是关系到活动的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从石英官方文档了解,AdoStore必须使用活动数据像存储JobDataMap中和其他数据。纠正我,如果我错了。

在这旁边的澄清,我想知道有没有办法从数据库中加载的工作和触发器的定义。一种插件或类似的东西的 Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin 是从XML文件中读取。

如果没有,是不是实现一个自定义插件,将从数据库中读取,或使用一些其他的方法呢?最好的解决办法

Rastko 2012年8月13日上午11时十六分28秒

从波纹管的回答我觉得我还没有介绍你的问题很好。 我想加载作业,然后从数据库触发器的配置。就像是在code或XML定义是这样的:

 <工作>
  <名称>&WriterJob LT; /名称>
  <组> CommonGroup< /组>
  <描述>试验WriteJob< /描述>
  <职业型> Console.WriteJob,控制台< /作业类型>
< /工作>
<触发>
  <简单>
    <名称>&WriterJobTrigger LT; /名称>
    <组> CommonTriggerGroup< /组>
    <描述>简单触发简单地火样的工作和LT; /描述>
    <作业名称>&WriterJob LT; /作业名称>
    <作业组> CommonGroup< /作业组>
    <失火指令> SmartPolicy< /失火指令>
    <重复计数> -1 LT; /重复计数>
    <重复间隔> 10000< /重复间隔>
  < /简单>
< /触发>
 

我要在数据库中以同样的方式都没有了。从对ADOJobStore生成的表格我看到这些表都比较为相关的当前活动的作业追踪 - 跟踪其状态,触发器触发,等等

我希望我更清楚了。要问我,如果你需要任何额外的说明。

解决方案
  

我想知道有没有办法从数据库中加载的工作和触发器的定义。

如果你正在寻找检索作业列表从数据库中,你可以这样做:

  Quartz.IScheduler调度;


   ....

  VAR细节=(从组名在scheduler.GetJobGroupNames()
                 从jobKey在scheduler.GetJobKeys(
                      Quartz.Impl.Matchers.GroupMatcher< Quartz.JobKey>
                      .GroupEquals(组名))
                选择新
                {
                    组名=组名,
                    作业名= jobKey.Name,
                    触发= scheduler.GetTriggersOfJob(jobKey)
                }
               );
 

本语法是石英2.0。

如果您是从实际执行作业的程序建立一个独立的程序,那么你只需创建一个具有相同的细节调度,但不叫scheduler.Start()

如果你正在寻找新的就业机会添加到您的数据库,你可以这样做:

(其中SimpleJob是你的工作的C#类的名称)

 串作业名称= ...
字符串triggerName = ...
字符串参赛者Cronex pression = ...
Quartz.IScheduler调度= ...


Quartz.IJobDetail的JobDetail = Quartz.JobBuilder.Create< SimpleJob>()
                    .WithIdentity(作业名)
                    .StoreDurably()
                    。建立();

Quartz.ITrigger触发= Quartz.TriggerBuilder.Create()
                    .WithIdentity(triggerName)
                    .WithSchedule(Quartz.CronScheduleBuilder.CronSchedule(参赛者Cronex pression)
                    .ForJob(作业名)
                    。建立();

scheduler.ScheduleJob(的JobDetail,触发器);
 

如果您想添加作业到数据库,而附加触发

  Quartz.IJobDetail的JobDetail = Quartz.JobBuilder.Create< SimpleJob>()
                    .WithIdentity(作业名)
                    .StoreDurably()
                    。建立();

scheduler.AddJob(的JobDetail,FALSE)
 

如果您想安排执行一次性现有的工作,那么

  Quartz.ITrigger触发器1 = Quartz.TriggerBuilder.Create()
                        .WithIdentity(triggerName)
                        .WithSchedule(Quartz.SimpleScheduleBuilder.Create())
                        .ForJob(作业名)
                        。建立();

   scheduler.ScheduleJob(触发器1);
 

As I understood from Quartz official documentation, AdoStore have to be used for active data storing like JobDataMap and other data. Correct me if I am wrong.

Beside of this clarification I would like to know is there any way to load job and trigger definition from database. Kind of plugin or something like the Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin is for reading from xml file.

If there is not, is it the best solution to implement a custom plugin that will read from database or to use some other approach?

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

From bellow answers I think that I have not describe you the problem good. I would like to load job and trigger configuration from database. Like it is 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 on the same way in DataBase. From generated tables for ADOJobStore I see that these tables are more related for tracking of the currently active jobs - tracking of its state, trigger firing, etc.

I hope that I more clear now. Be free to ask me if you need any additional clarification.

解决方案

I would like to know is there any way to load job and trigger definition from database.

If you are looking to retrieve a list of jobs 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 are building a separate program from the program that is actually executing the jobs, then you just create a scheduler with the same details but don't call scheduler.Start()

If you are looking to add new jobs 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 are looking to add a job to the database without attaching a trigger

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

scheduler.AddJob(jobDetail, false)

If you are looking to schedule execute a one-off existing job, then

   Quartz.ITrigger trigger1 = Quartz.TriggerBuilder.Create()
                        .WithIdentity(triggerName)
                        .WithSchedule(Quartz.SimpleScheduleBuilder.Create())
                        .ForJob(jobName)
                        .Build();

   scheduler.ScheduleJob(trigger1);

这篇关于石英工作专卖店是关系到活动的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆