Created
October 28, 2013 20:25
-
-
Save ck/7203964 to your computer and use it in GitHub Desktop.
Reuse connection in worker
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
(defrecord QueueWorker [queue worker-fn] | |
daemon/Daemon | |
(start [_] | |
(reset! done false) | |
(msg/with-connection {} ; use single connection for receive | |
(loop [] | |
(when-not @done | |
;; make sure we re-use the same HornetQ connection | |
(info "Worker Connection" (:connection ((get-thread-bindings) #'immutant.messaging.core/*options*))) | |
(when-let [msg (msg/receive queue :timeout 5000)] | |
(worker-fn msg)) | |
(recur))))) | |
(stop [_] | |
(reset! done true))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment