0

I have a scenario where I can have one-to-many Quartz scheduler instances running on a single server. Basically you can envision it as each department within the company getting it's own scheduler instance. Each scheduler is backed by it's own unique quartz database and each is wrapped up in it's own unique Windows Service. To illustrate better:

Server1

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

Server2

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

etc.

On a completely separate server I have a single web site that is used by ALL departments within the company. But this site needs to able to route through to the correct Quartz scheduler so that the user can schedule and maintain their own jobs as well as view existing jobs and their status etc. So for example, if I login to the web app as a member of the Sales dept I only want to see the jobs scheduled to the QuartzSalesDatabase and if I wish to schedule a new job I need a mechanism to get a handle on the required Sales_QuartzScheduler to do so. How best would this be accomplished? thanks

snappymcsnap
  • 2,050
  • 2
  • 29
  • 53

1 Answers1

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();
sgmoore
  • 15,694
  • 5
  • 43
  • 67
  • I haven't tried this with Quartz 2.1 yet but when we tried it in 1.x we ran into a scneario very similar to this one: https://groups.google.com/forum/?fromgroups#!searchin/quartznet/Multiple$20Job$20Stores$20in$20a$20Single$20Service/quartznet/PbtPd76kTKs/N5PNUxsLghQJ – snappymcsnap Jun 11 '13 at 13:56