Permalink
Browse files

Convert return values of confirm.* operations

  • Loading branch information...
1 parent e55621d commit e2823408ed8ea1b58b6b1e2bfc647915d0987bb6 Michael Klishin committed Feb 27, 2013
Showing with 40 additions and 4 deletions.
  1. +5 −4 src/clojure/langohr/confirm.clj
  2. +35 −0 src/java/com/novemberain/langohr/confirm/SelectOk.java
@@ -8,7 +8,8 @@
;; You must not remove this notice, or any other from this software.
(ns langohr.confirm
- (:import [com.rabbitmq.client Channel AMQP$Confirm$SelectOk ConfirmListener]))
+ (:import [com.rabbitmq.client Channel ConfirmListener]
+ com.novemberain.langohr.confirm.SelectOk))
;;
@@ -33,12 +34,12 @@
channel)
-(defn select
+(defn ^com.novemberain.langohr.confirm.SelectOk select
"Activates publishing confirmations on given channel."
([^Channel channel]
- (.confirmSelect channel))
+ (SelectOk. (.confirmSelect channel)))
([^Channel channel ack-handler nack-handler]
(let [select-ok (.confirmSelect channel)
cl (listener ack-handler nack-handler)]
(.addConfirmListener channel cl)
- select-ok)))
+ (SelectOk. select-ok))))
@@ -0,0 +1,35 @@
+package com.novemberain.langohr.confirm;
+
+import clojure.lang.IPersistentMap;
+import clojure.lang.PersistentHashMap;
+import com.novemberain.langohr.PersistentMapLike;
+import com.rabbitmq.client.AMQP;
+
+import java.util.HashMap;
+
+public class SelectOk extends PersistentMapLike implements AMQP.Confirm.SelectOk {
+ private final AMQP.Confirm.SelectOk method;
+
+ public SelectOk(AMQP.Confirm.SelectOk method) {
+ this.method = method;
+
+ this.map = mapFrom(method);
+
+ }
+
+ public static IPersistentMap mapFrom(AMQP.Confirm.SelectOk method) {
+ return PersistentHashMap.create(new HashMap());
+ }
+
+ public int protocolClassId() {
+ return method.protocolClassId();
+ }
+
+ public int protocolMethodId() {
+ return method.protocolMethodId();
+ }
+
+ public String protocolMethodName() {
+ return method.protocolMethodName();
+ }
+}

0 comments on commit e282340

Please sign in to comment.