I'm trying to get n messages from a queue (using langohr). I have a working version but I would like to know if there is a better clojurist way of doing this:
(def not-nil? (complement nil?))
(defn get_message [queue]
(let [[_ payload] (lb/get ch queue)]
(if (not-nil? payload)
(String. payload "UTF-8"))))
(take 4 (take-while not-nil? (repeatedly (partial get_message "my_queue"))))
So I fetch up to N messages as long as there are messages in the queue.
Is there a better clojurist way to do this?