我已经为Quartz.NET创建了数据库。将它配置为这样使用AdoJobStore:
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表中查找。我不知道出了什么问题。
有什么想法吗?
谢谢。
发布于 2011-06-07 06:09:48
我同意NinjaNye的观点。您必须使用API提交作业,因为它需要在运行时绑定类的命名空间。这个过程非常simple
// 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)。这将被调度程序用来在执行期间绑定我们的作业。
发布于 2011-06-07 04:09:51
您是否通过sql将作业直接添加到表中?如果是这样,请尝试通过代码使用api注册作业。如果没有其他情况,您可以检查添加的内容是否与api生成的数据匹配
https://stackoverflow.com/questions/6244358
复制相似问题