我正在尝试将Quartz.Net配置为在同一服务器上的两个站点上运行(实时和测试)。它当前没有运行(作业代码确实运行,在另一种配置中我在测试中将其触发,但仅在1种环境中有效)。任何帮助将不胜感激。
if (!isDevENV)
{
// construct a scheduler factory
NameValueCollection props = new NameValueCollection
{
{ "quartz.serializer.type", "binary" },
{ "quartz.scheduler.instanceName", "LocalServer_Live" },
{ "quartz.scheduler.instanceId", "LocalServer_Live" }
};
StdSchedulerFactory factory = new StdSchedulerFactory(props);
// get a scheduler
IScheduler Scheduler = factory.GetScheduler().Result;
Scheduler.Start();
IJobDetail testEmailJob = JobBuilder.Create<TestEmailJob>().WithIdentity("liveEmailJob", "liveGroup").Build();
ITrigger testEmailTrigger = TriggerBuilder.Create()
.WithIdentity("liveEmailTrigger", "live_group1")
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(3600)
.RepeatForever())
.Build();
Scheduler.UnscheduleJob(expirationsEmailTrigger.Key);
Scheduler.ScheduleJob(expirationsEmailjob, expirationsEmailTrigger);
}
else
{
// construct a scheduler factory
NameValueCollection props = new NameValueCollection
{
{ "quartz.serializer.type", "binary" },
{ "quartz.scheduler.instanceName", "LocalServer_Test" },
{ "quartz.scheduler.instanceId", "LocalServer_Test" }
};
StdSchedulerFactory factory = new StdSchedulerFactory(props);
// get a scheduler
IScheduler Scheduler = factory.GetScheduler().Result;
Scheduler.Start();
IJobDetail testEmailJob = JobBuilder.Create<TestEmailJob>().WithIdentity("testEmailJob", "testGroup").Build();
ITrigger testEmailTrigger = TriggerBuilder.Create()
.WithIdentity("testEmailTrigger", "group1")
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(3600)
.RepeatForever())
.Build();
Scheduler.UnscheduleJob(expirationsEmailTrigger.Key);
Scheduler.ScheduleJob(expirationsEmailjob, expirationsEmailTrigger);
}