55
66# Summary
77
8- [ Cronut-Javax] ( https://github.com/factorhouse/cronut-javax ) provides a data-first [ Clojure] ( https://clojure.org/ ) wrapper
9- for [ Quartz Scheduler] ( https://github.com/quartz-scheduler/quartz ) version ` 2.4.0 ` , compatible
8+ [ Cronut-Javax] ( https://github.com/factorhouse/cronut-javax ) provides a data-first [ Clojure] ( https://clojure.org/ )
9+ wrapper for [ Quartz Scheduler] ( https://github.com/quartz-scheduler/quartz ) version ` 2.4.0 ` , compatible
1010with [ Javax] ( https://jakarta.ee/blogs/javax-jakartaee-namespace-ecosystem-progress/ ) .
1111
1212Cronut supports ** in-memory** scheduling of jobs within a single JVM. JDBC and distributed jobstore are not supported.
@@ -15,7 +15,7 @@ Cronut supports **in-memory** scheduling of jobs within a single JVM. JDBC and d
1515
1616| Project | Desription | Clojars Project |
1717| ---------------------------------------------------------------------| ---------------------------------------------------------------------------| -------------------------------------------------------------------------------------------------------------------------------------------------|
18- | [ cronut] ( https://github.com/factorhouse/cronut ) | Cronut with [ Jakarta] ( https://en.wikipedia.org/wiki/Jakarta_EE ) support | [ ![ Clojars Project] ( https://img.shields.io/clojars/v/io.factorhouse/cronut.svg )] ( https://clojars.org/io.factorhouse/cronut ) |
18+ | [ cronut] ( https://github.com/factorhouse/cronut ) | Cronut with [ Jakarta] ( https://en.wikipedia.org/wiki/Jakarta_EE ) support | [ ![ Clojars Project] ( https://img.shields.io/clojars/v/io.factorhouse/cronut.svg )] ( https://clojars.org/io.factorhouse/cronut ) |
1919| [ cronut-integrant] ( https://github.com/factorhouse/cronut-integrant ) | [ Integrant] ( https://github.com/weavejester/integrant ) bindings for Cronut | [ ![ Clojars Project] ( https://img.shields.io/clojars/v/io.factorhouse/cronut-integrant.svg )] ( https://clojars.org/io.factorhouse/cronut-integrant ) |
2020
2121# Contents
@@ -27,9 +27,9 @@ Cronut supports **in-memory** scheduling of jobs within a single JVM. JDBC and d
2727 * [ Jobs] ( #jobs )
2828 + [ Job example] ( #job-example )
2929 * [ Triggers] ( #triggers )
30- - [ ` cronut.trigger/cron ` : Simple Cron Scheduling] ( #cronuttriggercron-simple-cron-scheduling )
31- - [ ` cronut.trigger/interval ` : Simple Interval Scheduling] ( #cronuttriggerinterval-simple-interval-scheduling )
32- - [ ` cronut.trigger/builder ` : Full trigger definition] ( #cronuttriggerbuilder-full-trigger-definition )
30+ - [ ` cronut.trigger/cron ` : Simple Cron Scheduling] ( #cronuttriggercron-simple-cron-scheduling )
31+ - [ ` cronut.trigger/interval ` : Simple Interval Scheduling] ( #cronuttriggerinterval-simple-interval-scheduling )
32+ - [ ` cronut.trigger/builder ` : Full trigger definition] ( #cronuttriggerbuilder-full-trigger-definition )
3333 * [ Concurrent execution] ( #concurrent-execution )
3434 + [ Global concurrent execution] ( #global-concurrent-execution )
3535 + [ Job-specific concurrent execution] ( #job-specific-concurrent-execution )
@@ -47,12 +47,12 @@ Cronut provides access to the Quartz Scheduler, exposed via the `cronut/schedule
4747
4848Create a scheduler with the following configuration:
4949
50- 1 . ` :concurrent-execution-disallowed? ` : (optional, default false) - run all jobs with @DisableConcurrentExecution
51- 2 . ` :update-check? ` : (optional, default false) - check for Quartz updates on system startup.
50+ 1 . ` :concurrent-execution-disallowed? ` : run all jobs with ` @DisableConcurrentExecution `
51+ 2 . ` :update-check? ` : check for Quartz updates on system startup.
5252
5353```` clojure
54- (cronut/scheduler {:concurrent-execution-disallowed? true
55- :update-check? false })
54+ (cronut/scheduler {:concurrent-execution-disallowed? true ; ; default false
55+ :update-check? false }) ; ; default false
5656````
5757
5858### Scheduler lifecycle
@@ -84,12 +84,8 @@ To schedule jobs, you can
8484
8585Each cronut job must implement the ` org.quartz.Job ` interface.
8686
87- The expectation being that every job will reify that interface either directly via ` reify ` or by returning a ` defrecord `
88- that implements the interface.
89-
90- Cronut supports further Quartz configuration of jobs (identity, description, recovery, and durability) by expecting
91- those values to be assoc'd onto your job. You do not have to set them (in fact in most cases you can likely ignore
92- them), however if you do want that control you will likely use the ` defrecord ` approach as opposed to ` reify ` .
87+ Cronut supports further Quartz configuration of jobs (identity, description, recovery, and durability) by passing an
88+ ` opts ` map when scheduling your job.
9389
9490Concurrent execution can be controlled on a per-job bases with the ` disallow-concurrent-execution? ` flag.
9591
@@ -104,22 +100,31 @@ Concurrent execution can be controlled on a per-job bases with the `disallow-con
104100
105101(let [scheduler (cronut/scheduler {:concurrent-execution-disallowed? true
106102 :update-check? false })
107- defrecord-job (map->TestDefrecordJobImpl {:identity [" name1" " group2" ]
108- :description " test job"
109- :recover? true
110- :durable? false })
103+ defrecord-job (map->TestDefrecordJobImpl {})
111104 reify-job (reify Job
112105 (execute [_this _job-context]
113106 (let [rand-id (str (UUID/randomUUID ))]
114107 (log/info rand-id " Reified Impl" ))))]
115108
116- (cronut/schedule-job scheduler (trigger/interval 1000 ) defrecord-job )
109+ (cronut/schedule-job scheduler
110+ (trigger/interval 1000 )
111+ defrecord-job
112+ {:name " name1"
113+ :group " group1"
114+ :description " test job 1"
115+ :recover? true
116+ :durable? false })
117117
118118 (cronut/schedule-job scheduler
119119 (trigger/builder {:type :cron
120120 :cron " */5 * * * * ?"
121121 :misfire :do-nothing })
122- reify-job))
122+ reify-job
123+ {:name " name2"
124+ :group " group1"
125+ :description " test job 2"
126+ :recover? false
127+ :durable? true }))
123128````
124129
125130## Triggers
@@ -153,20 +158,22 @@ The `cronut.trigger/builder` function supports the full set of Quartz configurat
153158
154159```` clojure
155160; ; interval
156- (cronut.trigger/builder {:type :simple
161+ (cronut.trigger/builder {:name " trigger1"
162+ :group " group3"
163+ :type :simple
157164 :interval 3000
158165 :repeat :forever
159- :identity [" trigger-two" " test" ]
160166 :description " sample simple trigger"
161167 :start #inst " 2019-01-01T00:00:00.000-00:00"
162168 :end #inst " 2019-02-01T00:00:00.000-00:00"
163169 :misfire :ignore
164170 :priority 5 })
165171
166172; ;cron
167- (cronut.trigger/builder {:type :cron
173+ (cronut.trigger/builder {:name " trigger2"
174+ :group " group3"
175+ :type :cron
168176 :cron " */6 * * * * ?"
169- :identity [" trigger-five" " test" ]
170177 :description " sample cron trigger"
171178 :start #inst " 2018-01-01T00:00:00.000-00:00"
172179 :end #inst " 2029-02-01T00:00:00.000-00:00"
@@ -207,7 +214,7 @@ See: integration test source: [test/cronut/integration-test.clj](test/cronut/int
207214 (:import (java.util UUID)
208215 (org.quartz Job)))
209216
210- (defrecord TestDefrecordJobImpl [identity description recover? durable? test-dep disallowConcurrentExecution? ]
217+ (defrecord TestDefrecordJobImpl []
211218 Job
212219 (execute [this _job-context]
213220 (log/info " Defrecord Impl:" this)))
@@ -231,10 +238,12 @@ See: integration test source: [test/cronut/integration-test.clj](test/cronut/int
231238 (log/info " scheduling defrecord job on 1s interval" )
232239 (cronut/schedule-job scheduler
233240 (trigger/interval 1000 )
234- (map->TestDefrecordJobImpl {:identity [" name1" " group2" ]
235- :description " test job"
236- :recover? true
237- :durable? false }))
241+ (map->TestDefrecordJobImpl {})
242+ {:name " name1"
243+ :group " group2"
244+ :description " test job"
245+ :recover? true
246+ :durable? false })
238247
239248 ; ; demonstrate scheduler can start with jobs, and jobs can start after scheduler
240249 (cronut/start scheduler)
@@ -247,7 +256,12 @@ See: integration test source: [test/cronut/integration-test.clj](test/cronut/int
247256 (trigger/builder {:type :cron
248257 :cron " */5 * * * * ?"
249258 :misfire :do-nothing })
250- reify-job)
259+ reify-job
260+ {:name " name2"
261+ :group " group2"
262+ :description " test job 2"
263+ :recover? false
264+ :durable? true })
251265
252266 (async/<!! (async/timeout 15000 ))
253267
0 commit comments