Skip to content

Commit

Permalink
queue-seq did not use its first argument (conn).
Browse files Browse the repository at this point in the history
This commit introduces an arity-overloaded version without the argument,
preserving the old signature for backwards-compatibility.

Also move the docstring into the correct place (before the argument
vector).

Corrects the example to use the new arity.
  • Loading branch information
rnewman committed Nov 7, 2009
1 parent 27c4ae2 commit be82bdd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/consumer.clj
Expand Up @@ -31,5 +31,5 @@
;; (println (rabbitmq/consume-poll conn-map channel)))

;; (let [[conn channel] connection]
;; (println (rabbitmq/queue-seq conn channel conn-map)))
;; (println (rabbitmq/queue-seq channel conn-map)))

19 changes: 12 additions & 7 deletions src/com/github/icylisper/rabbitmq.clj
Expand Up @@ -64,14 +64,19 @@
(.basicAck ch (.. d getEnvelope getDeliveryTag) false)
(cons m (delivery-seq ch q)))))

(defn queue-seq [conn
#^Channel ch
{q :queue}]
(defn queue-seq
"Return a sequence of the messages in queue with name queue-name"
(.queueDeclare ch q)
(let [consumer (QueueingConsumer. ch)]
(.basicConsume ch q consumer)
(delivery-seq ch consumer)))
([#^Channel ch
{q :queue}]
(.queueDeclare ch q)
(let [consumer (QueueingConsumer. ch)]
(.basicConsume ch q consumer)
(delivery-seq ch consumer)))
([conn
#^Channel ch
c]
(queue-seq ch c)))


;;; consumer routines
(defn consume-wait [c #^Channel ch]
Expand Down

0 comments on commit be82bdd

Please sign in to comment.