开发者

Can I persist Triggers myself in Quartz.NET?

开发者 https://www.devze.com 2023-03-22 20:44 出处:网络
My product already has the idea of tasks built into it.Currently they can be triggered by various system events.I would like to add the ability to schedule them, and Quarts.NET seems to be a good sche

My product already has the idea of tasks built into it. Currently they can be triggered by various system events. I would like to add the ability to schedule them, and Quarts.NET seems to be a good scheduling utility. However, I'm not interested in storing all my tasks as Quarts.NET jobs ... this seems like overkill for my purpose.

What I would like to do is simply add a property to my existing task object to store the开发者_如何学运维 Quarts.NET Trigger instance. This would be persisted in my own DB tables. When my app starts up, it will load tasks one by one, pull out the trigger and schedule it with the Scheduler.

Is this possible? Can I simply serialize the Trigger and store as xml?


Yes, both the CronTrigger and the SimpleTrigger are serializable.


Not sure if you can serialize triggers, but just like Java Quartz, Quartz.net has an XML plugin that allows you to store the Job- and Trigger configuration in an XML file. The plugin checks regularly to see if the file was updated, and will reconfigure the scheduling engine accordingly. Combine that with a RamJobStore and you'll have a pretty lightweight scheduling mechanism.

This post describes such a setup - the only thing you'd have to do is to assemble the job/trigger xml config file.

0

精彩评论

暂无评论...
验证码 换一张
取 消