如何获得由具有不同名称的零线程调度程序实例创建的JobDetails/Triggers? [英] How to get JobDetails/Triggers created by instances of zero thread scheduler with different names?

查看:98
本文介绍了如何获得由具有不同名称的零线程调度程序实例创建的JobDetails/Triggers?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Quartz.net 1.x迁移到2.x,由于某种原因,创建作业/触发器的调度程序的实例名称现在看来非常重要...在大多数情况下都添加了列SCHED_NAME如果创建该作业/触发器的零线程调度程序实例的名称与用于获取和显示它们的实例名称不同,则无法将所有石英表和它的数据库都存储在数据库中.

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...

我有一个用于创建大多数作业/触发器的UI,并且在我使用quartz.net 1.x时,我正在根据应用程序的功能区域创建具有不同名称的零线程调度程序实例,但我没有在使用其他名称的实例检索所有这些触发器时出现问题. 当我开始使用quartz.net 2.x时,由实例创建的作​​业/触发器与用于检索现有触发器以在UI中显示的实例名称不同,在使用IScheduler.GetJobDetailIScheduler.GetTriggersOfJob函数时未返回该实例,因此我修改了UI使用一个实例并解决了该问题.

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.

但是,我还有一个Windows服务,每次将文件放入FileSystemWatcher .NET对象观察到的热文件夹中时,该服务都会实例化我的自定义文件处理器对象,因此该文件处理器对象的每个实例都必须创建一个具有唯一名称的quartz.net零线程调度程序,用于调度作业以处理被删除的文件,因为可以同时删除多个文件,并且两个文件处理器对象实例试图创建夸脱实例.净零线程调度程序,其名称相同,这将导致quartz.net中的异常.结果,由Windows服务创建的这些作业/触发器不再对UI中使用的零线程调度程序可见,并且由Windows服务创建的这些触发器不再显示在我的UI中.

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.

无论如何,我的问题是,有没有一种方法可以从数据库中检索所有作业/触发器,而与quartz.net 2.x中的调度程序的实例名称无关,如果没有,是否有任何解决方法的想法这个问题? 另外,是否有人对为什么将SCHED_NAME添加到所有表中,为什么调度程序名称现在在2.x中如此重要以及进行此更改背后的想法有何见解?

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?

哇,刚刚花了几个小时试图弄清楚这一点,并且由于这个调度程序名称问题,似乎Quartz.net 2存在严重缺陷(除非我丢失了一些东西),这就是原因...

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...

由多线程调度程序忽略实例名称与多线程调度程序的实例名称不同的零线程调度程序创建的任何触发器,并且如果使用的所有调度程序都具有相同的实例名称(或者您让Quartz.net为所有调度程序提供默认实例名称),无法在多个并发线程上创建触发器,因为在这些线程上创建的所有零线程调度程序都使用相同的名称创建,这将导致Quartz中出现异常...

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...

推荐答案

我唯一能找到的解决方案是完全放弃为零线程或多线程调度程序提供实例名称.

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.

这将导致所有调度程序名称默认为QuartzScheduler,这将使我的UI用来显示和管理作业/触发器的零线程调度程序看到由任何调度程序创建的所有作业/触发器...

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...

我还通过将多个文件一次放入热文件夹中来测试了我的热文件夹,这导致使用其自己的零线程调度程序实例化多个自定义FileProcessor对象,每个对象都没有实例化,并且由于所有原因,Quartz均未引发异常这些使用相同的默认名称同时创建的零线程调度程序.

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.

这篇关于如何获得由具有不同名称的零线程调度程序实例创建的JobDetails/Triggers?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆