Liking cljdoc? Tell your friends :D

To start message queue You should do following steps:

  1. Create config:
(require '[datomic.api :as d])
(def conn (d/connect "your-datomic-db-uri"))
(def config 
  {:conn conn
   :q d/q
   :db d/db
   :transact d/transact-async
   :tiny-queue-processors {}})
  1. Transact tiny-queue schema:
(tq/create-schema config)
  1. Define your first custom job (first argument is a keyword - :db/ident, second argument is a doc string):
(tq/define-new-job config :qcommand/first-job "My first job!")
  1. Define first job processor (processor should return Datomic transaction):
(defn first-job-processor [[snapshot job uuid]]
  (println "Processing first job" uuid)
  [])
  1. Define proper tiny-queue-processors:
(def tiny-queue-processors {:qcommand/first-job first-job-processor})
  1. Start tiny-queue using wrap-background-job:
(require '[tiny-queue.core :as tq])
(def final-config (assoc config :tiny-queue-processors tiny-queue-processors))
(def background-processor (atom nil))
(reset! background-processor (future (wrap-background-job final-config 0)))
  1. Add new job to the tiny-queue:
(tq/create-new-job final-config {:command :qcommand/first-job
                                 :data "first-job-data"})

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close