首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Quartz.NET和AdoJobStore

Quartz.NET和AdoJobStore
EN

Stack Overflow用户
提问于 2011-06-06 00:51:31
回答 2查看 2.3K关注 0票数 2

我已经为Quartz.NET创建了数据库。将它配置为这样使用AdoJobStore:

代码语言:javascript
复制
        properties["quartz.scheduler.instanceName"] = "TestScheduler";
        properties["quartz.scheduler.instanceId"] = "instance_one";
        properties["quartz.threadPool.type"] = 
                   "Quartz.Simpl.SimpleThreadPool, Quartz";
        properties["quartz.threadPool.threadCount"] = "5";
        properties["quartz.threadPool.threadPriority"] = "Normal";
        properties["quartz.jobStore.misfireThreshold"] = "60000";
        properties["quartz.jobStore.type"] = 
                   "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
        properties["quartz.jobStore.useProperties"] = "true";
        properties["quartz.jobStore.dataSource"] = "default";
        properties["quartz.jobStore.tablePrefix"] = "Q";
        properties["quartz.jobStore.clustered"] = "true";
        // if running MS SQL Server we need this
        properties["quartz.jobStore.lockHandler.type"] = 
                   "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";

        properties["quartz.dataSource.default.connectionString"] = 
                   "Server=.;Database=Test;Trusted_Connection=True;";
        properties["quartz.dataSource.default.provider"] = "SqlServer-20";
        ISchedulerFactory sf = new StdSchedulerFactory(properties);
        IScheduler sched = sf.GetScheduler();

我在JOB_DETAILS表中添加了一个作业,并相应地在触发器和CRONTRIGGERS表中添加了触发器,但我的作业不会执行。我用SQL Server Profiler检查,Quartz执行的唯一查询是SELECT * FROM QSchedulerState。我使用sched.Start();启动调度程序,它不在JOB_DETAILS表中查找。我不知道出了什么问题。

有什么想法吗?

谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-06-07 06:09:48

我同意NinjaNye的观点。您必须使用API提交作业,因为它需要在运行时绑定类的命名空间。这个过程非常simple

代码语言:javascript
复制
// construct job info
JobDetail jobDetail = new JobDetail("myJob", null, typeof(HelloJob));
// fire every hour
Trigger trigger = TriggerUtils.MakeHourlyTrigger();
// start on the next even hour
trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow);  
trigger.Name = "myTrigger";
sched.ScheduleJob(jobDetail, trigger); 

正如您所看到的,我们正在向JobDetail传递作业的类型:typeof(HelloJob)。这将被调度程序用来在执行期间绑定我们的作业。

票数 3
EN

Stack Overflow用户

发布于 2011-06-07 04:09:51

您是否通过sql将作业直接添加到表中?如果是这样,请尝试通过代码使用api注册作业。如果没有其他情况,您可以检查添加的内容是否与api生成的数据匹配

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6244358

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档