我正在使用quartzite
,我需要在每个星期二早上(比如上午 10 点)安排一份工作。
我有这份工作的代码,但我不确定如何安排它。
我应该使用
daily
还是calendar
调度程序?我应该使用
with-interval-in-days
(如何)?
编辑:这是我到目前为止所拥有的,但它不起作用(见评论)。
(defn start-weekly-email-job []
(let [job (job/build
(job/of-type AlertMail)
(job/with-identity (job/key "jobs.weekly.1")))
trigger (trigger/build
(trigger/with-identity (trigger/key "triggers.1"))
(trigger/start-at (time-of-day 10 00 00))
; at 10 AM, fails with exception
; IllegalArgumentException No implementation of method: :to-date of protocol: #'clojurewerkz.quartzite.conversion/DateConversion found for class: org.quartz.TimeOfDay clojure.core/-cache-protocol-fn (core_deftype.clj:554)
(trigger/with-schedule (daily/schedule
(daily/on-days-of-the-week #{(int 2)}))))] ;; ;; start Tuesday
(qs/schedule s job trigger)))
编辑2:
使用每日间隔计划 每日间隔计划可以轻松定义计划,例如
- “周一至周五 9 点至 17 点”
- “每个周末凌晨三点”
- “每周五中午”
- “每天13:45”
- “星期四每小时,但不迟于 15:00,总共最多 400 次”
我的案例与文档中突出显示的案例非常相似,但我无法找到如何使用每日时间表。