我需要以编程方式根据触发器选择用于特定作业的调度程序。 我不知道我要在哪里解决。
这是石英应用程序配置部分:
<quartz>
<add key="quartz.scheduler.instanceName" value="ServerScheduler" />
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="Normal" />
<add key="quartz.scheduler.exporter.type" value="Quartz.Simpl.RemotingSchedulerExporter, Quartz" />
<add key="quartz.scheduler.exporter.port" value="555" />
<add key="quartz.scheduler.exporter.bindName" value="QuartzScheduler" />
<add key="quartz.scheduler.exporter.channelType" value="tcp" />
<add key="quartz.jobStore.misfireThreshold" value="40000" />
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
<add key="quartz.jobStore.clustered" value="true" />
<add key="quartz.jobStore.maxMisfiresToHandleAtATime" value="40" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
<add key="quartz.dataSource.default.connectionString" value="Integrated Security=SSPI;Pooling=false;Data Source=(local)\SQLEXPRESS;Initial Catalog=XXX" />
<add key="quartz.dataSource.default.provider" value="SqlServer-20" />
</quartz>
然后我们的服务如下:
public void ScheduleJob(ITrigger trigger)
{
IScheduler scheduler = WMSScheduler.GetScheduler();
try
{
scheduler.ScheduleJob(trigger);
}
catch (SocketException)
{
throw new Exception(CaptionHelper.GetLocalizedText(@"Messages\Common", "QuartzNotRunning"));
}
}
public static IScheduler GetScheduler()
{
if (scheduler == null)
{
scheduler = BuildScheduler();
}
return scheduler;
}
public static bool IsSchedulerStarted()
{
string proxyAddress = GetProxyAddress();
Uri uri;
if (Uri.TryCreate(proxyAddress, UriKind.RelativeOrAbsolute, out uri))
{
return IsPortListening(uri);
}
throw new InvalidOperationException("The configured Scheduler address is incorrect.");
}
此功能不是由我开发的,所以我仍在学习并试图了解其工作原理。
据我所知,目前在2台服务器上有2个Quartz主机,我们无法指出Quartz主机做了什么,但有时我们想要指导哪个服务器完成了什么。
有什么想法吗?