Quartz.Net 作业存储查询
我正在当前项目中使用 Quartz.NET 创建调度程序。就我而言,所有需要创建的作业都存储在一个表中,并且有一个单独的 UI,我可以在其中添加新作业或编辑现有作业。我的问题是如何将表中的所有作业提供给 Quartz 调度程序?我是否想要查询表中的所有作业并迭代它以创建 JobDetails 和 Trigger 对象?这种情况下还有更好的办法吗?
在这种情况下,我想使用 RAMJobStore 还是 AdoJobStore?
I'm creating a scheduler using Quartz.NET in the current project. In my case all the jobs that has to be created are stored in a single table and there is a separate UI where I can add new jobs or edit existing jobs. My question is how I can feed all the jobs in the table to the Quartz scheduler? Do I want to query for all the jobs in the table and iterate through it creating the JobDetails and Trigger objects? Is there any better way in this case?
In this case do I want to use a RAMJobStore or AdoJobStore?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 AdoJobStore。
Quartz.net 将在数据库中使用一组带有前缀
QRTZ_
(您可以根据需要更改它)的表来存储这些对象的作业、触发器和状态。我想您希望在数据库中有一个表来保存有关您的日程安排的扩展信息,对吗?
您不会直接访问 Quartz.net 表,因为您将使用 Quartz.net 提供的 API。
创建作业详细信息和触发器的过程非常简单,并且在教程中进行了很好的描述。
要将您的应用配置为使用 AdoJobStore,您必须在 app.config 文件中指定一些信息。
下面是一个示例:
有几件事情需要记住,具体取决于您是否在 Web 应用程序、服务或 winform 应用程序中托管 Quartz.net。
最好的方法是将 SchedulerFactory 和 Scheduler 创建为单例。
您可以在此处收集更多信息。
更新:
首先,您必须创建 Quartz.net 表(请参阅第 1 步),然后您必须创建一些索引以进行优化(请参见页面)。
由于您将使用 Web 应用程序提交作业,但您不使用该应用程序来处理quartz.net 事件(触发器),因此您不需要启动调度程序。
这方面需要遵循几个步骤:
您必须将线程池类型更改为 ZeroSizeThreadPool,
并且必须定义 StdSchedulerFactory 和 Scheduler 单例。您可以在应用程序 (asp.net) 引导期间启动。
您永远不会启动调度程序(您的 Windows 服务将使用它)。
另一件要记住的事情是,您需要在 Web 和 Windows 服务之间共享您的作业,因此最好将其保留在单独的程序集中。
您提到您正在一张表中存储一些信息。
您仍然需要提交作业和触发器,它们将保留在 Quartz.net 表中。
you can use AdoJobStore.
Quartz.net will use a set of tables with prefix
QRTZ_
(you can change it if you want) in your database to stored jobs, triggers and status of these objects.I guess you want to have a table in your DB where you're going to keep extended information about your schedules, right?
You won't access Quartz.net table directly cause you will use the APIs provided by Quartz.net.
The process to create a job detail and trigger is straightforward and described very well in the tutorials.
To configure your app to use the AdoJobStore you have to specify few informations in your app.config file.
Here is an example:
There are few things to keep in mind depending if you're hosting Quartz.net in a web application or a service or winform app.
The best approach is to create SchedulerFactory and Scheduler as singleton.
You can gather some more infos here.
UPDATE:
First of all you have to create Quartz.net tables (see Step 1) and then you'll have to create a few indexes for optiomization (see bottom of the page).
Since you're going to submit your jobs using the web app but you're not using that app for the quartz.net events (triggers) you don't need to start the scheduler.
There are few steps to follow on this side:
you have to change the thread pool type to ZeroSizeThreadPool
and you have to define your StdSchedulerFactory and Scheduler singleton. You can start during the application (asp.net) bootstrap.
You're never going to start the Scheduler (your windows service is going to use that).
Another thing to remember is you're going to need share your job between your web and your windows service, so it would be better to keep it in a separate assembly.
You mentioned you're storing some infos in one of your table.
You still need to have to submit your jobs and trigger which will be persisted in Quartz.net tables.