0

我有一个场景,我可以在单个服务器上运行一对多的 Quartz 调度程序实例。基本上,您可以将其设想为公司内的每个部门都拥有自己的调度程序实例。每个调度程序都有自己独特的石英数据库支持,每个调度程序都包含在自己独特的 Windows 服务中。为了更好地说明:

服务器1

  • Accounting_WindowsService --> Accounting_QuartzScheduler --> QuartzAccountingDatabase
  • Sales_WindowsService --> Sales_QuartzScheduler --> QuartzSalesDatabase
  • IT_WindowsService --> IT_QuartzScheduler --> QuartzITDatabase

服务器2

  • Management_WindowsService --> Management_QuartzScheduler --> QuartzManagementDatabase
  • HR_WindowsService --> HR_QuartzScheduler --> QuartzHRDatabase

等等

在完全独立的服务器上,我有一个供公司所有部门使用的网站。但是该站点需要能够路由到正确的 Quartz 调度程序,以便用户可以调度和维护自己的作业以及查看现有作业及其状态等。例如,如果我以会员身份登录 Web 应用程序销售部门的我只想查看安排到 QuartzSalesDatabase 的作业,如果我想安排一个新作业,我需要一种机制来处理所需的 Sales_QuartzScheduler。这将如何最好地完成?谢谢

4

1 回答 1

0

I need a mechanism to get a handle on the required Sales_QuartzScheduler.

Actually all you need is a similarly configured scheduler. Hence you can just do exactly the same as you do for your service but don't actually start the scheduler.

For example, something like this would work

var  col = new System.Collections.Specialized.NameValueCollection();
col.Add("quartz.threadPool.threadCount" ,"10" );
col.Add("quartz.threadPool.threadPriority" ,"Normal" );
col.Add("quartz.jobStore.misfireThreshold" ,"60000" );
col.Add("quartz.jobStore.type" ,"Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" );
col.Add("quartz.jobStore.useProperties" ,"false" );
col.Add("quartz.jobStore.dataSource" ,"default" );
col.Add("quartz.jobStore.tablePrefix", "QRTZ_");
col.Add("quartz.jobStore.clustered" ,"true" );
col.Add("quartz.jobStore.lockHandler.type" ,"Quartz.Impl.AdoJobStore.SimpleSemaphore, Quartz" );
col.Add("quartz.dataSource.default.provider" ,"SqlServer-20" ); 


col.Add("quartz.scheduler.instanceName",  ... );
col.Add("quartz.scheduler.instanceId" ,  ... );
col.Add("quartz.dataSource.default.connectionString" , ...);


var schedulerFactory = new Quartz.Impl.StdSchedulerFactory();
schedulerFactory.Initialize(col);

var scheduler = schedulerFactory.GetScheduler();
于 2013-06-07T18:43:07.230 回答