Clojure wrapper for Jesque
To use the latest release, add the following to your deps.edn
(Clojure CLI)
co.gaiwan/cljesque {:mvn/version "0.4.11"}
or add the following to your project.clj
(Leiningen)
[co.gaiwan/cljesque "0.4.11"]
Many projects need some kind of task runner for doing background processes. In the Ruby world Resque is a very common solution to this, Jesque is a compatible Java port. This project makes it a bit easier to work with from Clojure.
The Java version expects you to create a new class for each Job type. We hijack the classname field to instead store the fully qualified name of a Clojure function (var), which gets resolved (via requiring-resolve) on the worker.
You can spin up any number of worker machines/processes, as long as they can reach redis, and can load the necessary functions.
Since Jesqueue is compatible with Resqueue, you can use Resqueue-web as dashboard UI.
(require '[co.gaiwan.cljesque :as q])
;; Set up Redis connection pool and Jesque client
(def client (q/connect))
;; OR
(def client (q/connect {:host "127.0.0.1" :port 6379}))
;; "Job" function
(defn test-fn [inj arg1 arg2]
(println "TEST" inj arg1 arg2))
;; Schedule jobs
(dotimes [i 10]
(q/enqueue client "test-queue" `test-fn "first-arg" (str "second-arg-" i)))
;; Run a worker
(def injected-values {... db,config etc ...})
(q/run-worker! client ["test-queue"] injected-values)
;; Check what's in the queue(s)
(q/queue-infos client)
Copyright © 2025 Gaiwan GmbH and Contributors
Licensed under the term of the Apache Software License, Version 2.0, see LICENSE.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |