向 Quartz CronTrigger 添加一次性额外触发
我想知道如何采用 CronTrigger 并添加额外的一次性触发,以便我可以像使用 getFileTimeAfter(Date) 方法一样迭代触发时间
假设我有一个 CronTrigger 表示为:“0 0 12 * *?”
我如何添加一个额外的触发,如 SimpleTrigger 所表达的,不重复?
I was wondering how I might take a CronTrigger and add an extra one-off firing such that I can iterate over the firing times as I might with the getFileTimeAfter(Date) method
Say if I had a CronTrigger expressed by: "0 0 12 * * ?"
How might I add one additional firing as might be expressed by a SimpleTrigger with no repeat?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CronTrigger
本身不可能做到这一点。 不过,您可以根据需要将任意多个不同的触发器与给定的JobDetail
关联起来。您可以通过注册
CronTrigger
和SimpleTrigger
来模拟您想要实现的目标,在每个触发器上调用getFireTimeAfter
并获取较早的值。令人烦恼的是,
getFireTimeAfter
出现在CronTrigger
和SimpleTrigger
上,但不在Trigger
接口中。 请注意,这是 Quartz API 中最小的错误。This isn't possible with
CronTrigger
itself. You can, however, associate as many different Triggers with a givenJobDetail
as you like.You could simulate what you're trying to achieve by registering your
CronTrigger
plus aSimpleTrigger
, callgetFireTimeAfter
on each trigger, and take the earlier value.Annoyingly,
getFireTimeAfter
is present on bothCronTrigger
andSimpleTrigger
, but isn't in theTrigger
interface. That's the least of Quartz's API sins, mind you.