Permalink
Browse files

Breaking change: make delivery handler signatures consistent everywhere

  • Loading branch information...
1 parent 8e8e118 commit 4585f2d2f387edf4c7fc5adf43e340d36ed7c310 @michaelklishin committed Sep 22, 2012
Showing with 34 additions and 10 deletions.
  1. +18 −0 ChangeLog.md
  2. +15 −9 src/clojure/langohr/consumers.clj
  3. +1 −1 test/langohr/test/consumers_test.clj
View
@@ -1,3 +1,21 @@
+## Changes between Langohr 1.0.0-beta5 and 1.0.0-beta6
+
+`1.0.0-beta6` has **BREAKING CHANGES**:
+
+### langohr.basic/consume Delivery Handler Signature Change
+
+`langohr.basic/consume`'s `:handle-delivery-fn` signature is now consistent with
+that of `langohr.basic/subscribe`:
+
+``` clojure
+(fn [^Channel ch metadata ^bytes payload]
+ )
+```
+
+This makes delivery handler signatures consistent everywhere.
+
+
+
## Changes between Langohr 1.0.0-beta4 and 1.0.0-beta5
### More Connection Settings
@@ -8,7 +8,6 @@
;; You must not remove this notice, or any other, from this software.
(ns langohr.consumers
- (:refer-clojure :exclude [get])
(:import [com.rabbitmq.client Channel Consumer DefaultConsumer QueueingConsumer QueueingConsumer$Delivery ShutdownSignalException Envelope AMQP$BasicProperties QueueingConsumer$Delivery])
(:require [langohr.basic :as lhb])
(:use langohr.conversion))
@@ -41,19 +40,26 @@
(when recover-ok-fn
(recover-ok-fn)))
- (handleShutdownSignal [^String consumer-tag, ^ShutdownSignalException sig]
+ (handleShutdownSignal [^String consumer-tag ^ShutdownSignalException sig]
(when shutdown-signal-fn
(shutdown-signal-fn consumer-tag sig)))
- (handleDelivery [^String consumer-tag, ^Envelope envelope, ^AMQP$BasicProperties properties, ^bytes body]
+ (handleDelivery [^String consumer-tag ^Envelope envelope ^AMQP$BasicProperties properties ^bytes body]
(when handle-delivery-fn
(let [delivery (QueueingConsumer$Delivery. envelope properties body)]
- (handle-delivery-fn delivery properties body))))))
+ (handle-delivery-fn channel (to-message-metadata delivery) body))))))
(defn subscribe
"Adds new blocking default consumer to a queue using basic.consume AMQP method"
- [^Channel channel ^String queue f & options]
- (let [queueing-consumer (create-default channel
- :handle-delivery-fn (fn [delivery properties body]
- (f channel (to-message-metadata delivery) body)))]
- (apply lhb/consume channel queue queueing-consumer (flatten (vec options)))))
+ [^Channel channel ^String queue f & {:as options}]
+ (let [keys [:handle-consume-ok :handle-cancel :handle-cancel-ok :handle-recover-ok :handle-shutdown-signal]
+ cons-opts (select-keys options keys)
+ options' (apply dissoc (concat [options] keys))
+ consumer (create-default channel
+ :handle-delivery-fn f
+ :handle-consume-ok (get cons-opts :handle-consume-ok)
+ :handle-cancel-ok (get cons-opts :handle-cancel-ok)
+ :handle-cancel (get cons-opts :handle-cancel)
+ :handle-recover-ok (get cons-opts :handle-recover-ok)
+ :handle-shutdown-signal (get cons-opts :handle-shutdown-signal))]
+ (apply lhb/consume channel queue consumer (flatten (vec options')))))
@@ -58,7 +58,7 @@
n 300
latch (java.util.concurrent.CountDownLatch. (inc n))
consumer (lhcons/create-default channel
- :handle-delivery-fn (fn [delivery message-properties message-payload]
+ :handle-delivery-fn (fn [ch metadata ^bytes payload]
(.countDown latch))
:consume-ok-fn (fn [consumer-tag]
(.countDown latch)))]

0 comments on commit 4585f2d

Please sign in to comment.