问题
I'm migrating from Quartz.net 1.x to 2.x and for some reason the instance name of the scheduler that created job/trigger now appears to be very important... Column SCHED_NAME
was added to most of the quartz tables and it apperas there is no way to get all the jobs/triggers stored in the database if zero thread scheduler instance(s) that created these jobs/triggers had different names from the instance used to fetch and display them...
Here is a little bit more detail about how I'm using quartz to help you better understand the question...
I have a UI that is used to create most jobs/triggers and while I was using quartz.net 1.x I was creating instances of zero thread scheduler with different names depending of the functional area of the app and I had no problem retreiving all these triggers by an instance with a different name.
When I started using quartz.net 2.x the jobs/triggers created by instances named differently than the instance used to retreive existing triggers for display in UI where not being returned when using IScheduler.GetJobDetail
and IScheduler.GetTriggersOfJob
functions so I modified the UI to use a single instance and that resolved that problem.
However, I also have a windows service and this service instantiates my custom File Processor object every time a file is dropped into a hot folder observed by a FileSystemWatcher
.NET object so every instance of this File Processor object must create a quartz.net zero thread scheduler with a unique name in order to schedule a job to process the file that was dropped because multiple files could be dropped at the same time and if two instances of File Processor objects attempted to create an instance of the quart.net zero thread scheduler with the same name that would cause an exception in quartz.net. As a result these jobs/triggers created by the windows service are no longer visible to the zero thread scheduler used in the UI and these triggers created by the windows service are no longer displayed in my UI.
Anyway, my question is is there a way to retreive all the jobs/triggers from the database regardless of the instance name of the scheduler in quartz.net 2.x, and if not, are there any ideas on how to resolve this problem?
Also, does anyone have any insight into why was SCHED_NAME
added to all the tables, why is scheduler name now so important in 2.x and what was the thinking behind making this change?
EDIT: Wow, just spent several hours trying to figure this out and it appears that (unless I'm missing something) that Quartz.net 2 is deeply flawed because of this scheduler name issue and here is why...
Any triggers created by zero-thread schedulers with instance name different from the instance name of the multi-thread scheduler will be just ignored by the multi-thread scheduler and if all the schedulers used have the same instance name (or you let Quartz.net give all the schedulers default instance name) creating triggers on multiple simultaneous threads becomes impossible because all the zero-thread schedulers created on these threads are created with the same name and that would cause an exception in Quartz...
回答1:
The only solution I was able to find is to completely give up on providing instance names for either the zero-thread or multi-thred schedulers.
This results in all scheduler names defaulting to QuartzScheduler
and that makes all the jobs/trigger created by any scheduler visible to the zero-thread scheduler used by my UI to display and manage jobs/triggers...
I also tested my hot folders by droping multiple files at once into the hot folder which resulted in instantiation of multiple custom FileProcessor
objects with each one using its own zero-thread scheduler and no exceptions were raised by Quartz due to all these simultaneously created zero-thread schedulers using the same default name.
I would prefer to be able to continue using different instance names for different schedulers but this resolved the problem so it's an acceptable solution.
来源:https://stackoverflow.com/questions/14965860/how-to-get-jobdetails-triggers-created-by-instances-of-zero-thread-scheduler-wit