-
Notifications
You must be signed in to change notification settings - Fork 1
Advanced usage
Sebastian Jylanki edited this page Sep 28, 2016
·
3 revisions
(let [xsub (socket :xsub "@tcp://*:*")
xpub (doto (socket :xpub "@tcp://*:*") (proxy! xsub))
pubs (vec (for [_ (range 5)]
(doto (socket :pub) (connect! xsub))))
subs (vec (for [_ (range 10)]
(doto (socket :sub)
(connect! xpub)
(subscribe! ""))))]
(doseq [[i s] (map-indexed vector pubs)] (send! s (str i)))
(Thread/sleep 100) ; give enough time for messages to pass
(let [msgs-s1 (vec (map #(String. %) (recv-all-messages! (first subs))))]
(doseq [s (rest subs)]
(assert (= (vec (map #(String. %) (recv-all-messages! s)))
msgs-s1)))))
proxy!
here emulates ZMQ_PROXY functionality using a pair of core.async
pipes.
Please have a look at the tests. There are plenty of interesting examples, some of which are slightly advanced.