Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Import methods from langohr
- (require '[langohr.core :as rmq]
- '[langohr.channel :as lch]
- '[langohr.queue :as lq]
- '[langohr.exchange :as le]
- '[langohr.consumers :as lc]
- '[langohr.basic :as lb])
- (defn start-alert-consumer
- "Starts a consumer bound to the given topic exchange in a separate thread"
- [ch ex]
- (let [queue "ALERT"
- handler (fn [ch {:keys [content-type delivery-tag type] :as meta} ^bytes payload]
- (println (format "received %s" (String. payload "UTF-8"))))]
- (lq/declare ch queue))
- (lq/bind ch queue ex)
- (lc/subscribe ch queue handler)))
- (defn -main
- "Start RabbitMQ consumer"
- [& args]
- (let [conn (rmq/connect {:host "192.168.99.101"})
- ch (lch/open conn)
- ex "data"]
- (le/declare ch ex "direct" {:durable true})
- (start-alert-consumer ch ex)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement