Dead-simple Google Cloud Pub/Sub from Clojure. jonotin is a never used Finnish word for a thing that queues. Read more about jonotin from IPRally blog.
Copy the code. It's too simple for library and we don't have enough time for updating the binaries.
(jonotin/publish! {:project-name "my-gcloud-project"
:topic-name "my-topic"
:messages ["msg1" "msg2"]})
Subscribe processed messages from the queue until the queue is empty. Batch size is the number of messages fetched from the queue at once.
(jonotin/subscribe! {:project-name "my-gcloud-project"
:subscription-name "my-subscription-name"
:batch-size 10
:handle-msg-fn (fn [msg]
(println "Handling" msg)
:handle-error-fn (fn [e]
(println "Oops!" e))})
We use it with at-at, so that subscribe is tried every 30s when queue is empty.
(let [pool (at-at/mk-pool)]
(at-at/interspaced 30000
(fn []
(jonotin/subscribe! {:project-name (config/get-property [:pubsub :project-name])
:subscription-name (config/get-property [:pubsub :subscription])
:batch-size 10
:handle-msg-fn handle-msg!
:handle-error-fn handle-error!})
(log/info "All EP patents imported from pub/sub queue"))
pool))
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close