如何创建自定义 Quartz 触发器?
我搜索了谷歌,但找不到有关如何创建自定义触发器的文章/教程。任何指示/建议都有帮助。自定义触发器应等到满足以下两个条件,然后触发作业
- 时间已过下午 5 点
- 具有特定值的记录(例如行 id 10 的列值更改为“START”)已到达给定表
I searched google but couldn't find articles/tutorials on how to create a custom trigger. Any pointers/suggestions are helpful. The custom trigger should wait until the below two conditions are met and then trigger a job
- Time is past 5 PM
- A record with particular value (say a column value for row id 10 is changed to "START") has arrived in a given table
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我同意sjr。我只需使用 cronExpression
0 0/5 17-23 * * ?
创建一个CronTrigger
(这样它就会从下午 5 点开始每 5 分钟触发一次 - 根据情况调整频率您的具体要求),然后在作业执行时检查数据库条件。I agree with sjr. I would just create a
CronTrigger
with cronExpression0 0/5 17-23 * * ?
(so it would fire every 5 minutes starting at 5 PM - adjust the frequency depending on your exact requirements) , and then check the database conditions upon job execution.免责声明:我以前没有使用过 Quartz,但是查看 javadoc
Trigger
看起来很难实现。难道你不能每分钟或每小时或其他什么时间运行你的工作,并将类似以下内容放在顶部:Disclaimer: I haven't used Quartz before, but looking at the javadoc
Trigger
looks hard enough to implement. Can't you just run your job every minute or hour or whatever and put something like the following up the top: