This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn pipe | |
"Returns a vector containing a sequence that will read from the | |
queue, and a function that inserts items into the queue. | |
Source: http://clj-me.cgrand.net/2010/04/02/pipe-dreams-are-not-necessarily-made-of-promises/" | |
[] | |
(let [q (LinkedBlockingQueue.) | |
EOQ (Object.) | |
NIL (Object.) | |
s (fn queue-seq [] |