From be82bdd2e293de02bc348e4d23ae56b6959dbac7 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Fri, 6 Nov 2009 20:48:47 -0800 Subject: [PATCH] queue-seq did not use its first argument (conn). 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. --- example/consumer.clj | 2 +- src/com/github/icylisper/rabbitmq.clj | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/example/consumer.clj b/example/consumer.clj index 5d0fa2a..b01b3b2 100644 --- a/example/consumer.clj +++ b/example/consumer.clj @@ -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))) diff --git a/src/com/github/icylisper/rabbitmq.clj b/src/com/github/icylisper/rabbitmq.clj index e6fd1c6..458bcf4 100644 --- a/src/com/github/icylisper/rabbitmq.clj +++ b/src/com/github/icylisper/rabbitmq.clj @@ -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]