Skip to content
Browse files

Convert return values of tx.* operations

  • Loading branch information...
1 parent e282340 commit a8c7e0792bc62829a99c41969e575132901e59a0 Michael Klishin committed Feb 27, 2013
View
18 src/clojure/langohr/tx.clj
@@ -8,24 +8,26 @@
;; You must not remove this notice, or any other, from this software.
(ns langohr.tx
- (:import com.rabbitmq.client.Channel))
+ (:import com.rabbitmq.client.Channel
+ [com.novemberain.langohr.tx SelectOk CommitOk RollbackOk]))
;;
;; API
;;
-(defn select
- "Activates transactions on given channel. Please note that transactions only cover publishing and acknowledgements."
+(defn ^com.novemberain.langohr.tx.SelectOk select
+ "Activates transactions on given channel. Please note that transactions only
+ cover publishing and acknowledgements, not delivery to consumers."
[^Channel channel]
- (.txSelect channel))
+ (SelectOk. (.txSelect channel)))
-(defn commit
+(defn ^com.novemberain.langohr.tx.CommitOk commit
[^Channel channel]
- (.txCommit channel))
+ (CommitOk. (.txCommit channel)))
-(defn rollback
+(defn ^com.novemberain.langohr.tx.CommitOk rollback
[^Channel channel]
- (.txRollback channel))
+ (RollbackOk. (.txRollback channel)))
View
35 src/java/com/novemberain/langohr/tx/CommitOk.java
@@ -0,0 +1,35 @@
+package com.novemberain.langohr.tx;
+
+import clojure.lang.IPersistentMap;
+import clojure.lang.PersistentHashMap;
+import com.novemberain.langohr.PersistentMapLike;
+import com.rabbitmq.client.AMQP;
+
+import java.util.HashMap;
+
+public class CommitOk extends PersistentMapLike implements AMQP.Tx.CommitOk {
+ private final AMQP.Tx.CommitOk method;
+
+ public CommitOk(AMQP.Tx.CommitOk method) {
+ this.method = method;
+
+ this.map = mapFrom(method);
+
+ }
+
+ public static IPersistentMap mapFrom(AMQP.Tx.CommitOk method) {
+ return PersistentHashMap.create(new HashMap());
+ }
+
+ public int protocolClassId() {
+ return method.protocolClassId();
+ }
+
+ public int protocolMethodId() {
+ return method.protocolMethodId();
+ }
+
+ public String protocolMethodName() {
+ return method.protocolMethodName();
+ }
+}
View
35 src/java/com/novemberain/langohr/tx/RollbackOk.java
@@ -0,0 +1,35 @@
+package com.novemberain.langohr.tx;
+
+import clojure.lang.IPersistentMap;
+import clojure.lang.PersistentHashMap;
+import com.novemberain.langohr.PersistentMapLike;
+import com.rabbitmq.client.AMQP;
+
+import java.util.HashMap;
+
+public class RollbackOk extends PersistentMapLike implements AMQP.Tx.RollbackOk {
+ private final AMQP.Tx.RollbackOk method;
+
+ public RollbackOk(AMQP.Tx.RollbackOk method) {
+ this.method = method;
+
+ this.map = mapFrom(method);
+
+ }
+
+ public static IPersistentMap mapFrom(AMQP.Tx.RollbackOk method) {
+ return PersistentHashMap.create(new HashMap());
+ }
+
+ public int protocolClassId() {
+ return method.protocolClassId();
+ }
+
+ public int protocolMethodId() {
+ return method.protocolMethodId();
+ }
+
+ public String protocolMethodName() {
+ return method.protocolMethodName();
+ }
+}
View
35 src/java/com/novemberain/langohr/tx/SelectOk.java
@@ -0,0 +1,35 @@
+package com.novemberain.langohr.tx;
+
+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.Tx.SelectOk {
+ private final AMQP.Tx.SelectOk method;
+
+ public SelectOk(AMQP.Tx.SelectOk method) {
+ this.method = method;
+
+ this.map = mapFrom(method);
+
+ }
+
+ public static IPersistentMap mapFrom(AMQP.Tx.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 a8c7e07

Please sign in to comment.
Something went wrong with that request. Please try again.