Skip to content

Instantly share code, notes, and snippets.

@danlentz
Forked from pingles/better.clj
Created February 18, 2014 06:29
Show Gist options
  • Save danlentz/9065637 to your computer and use it in GitHub Desktop.
Save danlentz/9065637 to your computer and use it in GitHub Desktop.
(defn subscriber-seq
[ch qname]
(let [[message-seq put] (pipe)]
(letfn [(message-handler [ch msg-meta payload])
(put {:ch ch :msg-meta msg-meta :payload payload})]
(lc/subscribe ch qname message-handler :auto-ack true))
message-seq))
(defn payload-str
[x]
(String. payload "UTF-8")
(map (comp read-json payload-str :payload)
(subscriber-seq ch qname))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment