     int))
 
 (defn work [m]
-  (csh/swap-in! cache :a (constantly 1))
-  (msg/publish queue "kiwi")
-  (msg/publish remote-queue "starfruit")
-  (not-supported
-    (csh/swap-in! cache :deliveries (fnil inc 0)))
-  (sql/with-db-transaction [t spec]
-    (write-thing-to-db t "tangerine")
-    (when (:throw? m) (throw (Exception. "rollback")))
-    (when (:rollback? m)
-      (set-rollback-only)
-      (sql/db-set-rollback-only! t))))
+  (let [{:keys [non-tx-cache? throw? rollback?]} m
+        cache (if non-tx-cache? non-tx-cache tx-cache)]
+    (csh/swap-in! cache :a (constantly 1))
+    (msg/publish queue "kiwi")
+    (msg/publish remote-queue "starfruit")
+    (not-supported
+      (csh/swap-in! cache :deliveries (fnil inc 0)))
+    (sql/with-db-transaction [t spec]
+      (write-thing-to-db t "tangerine")
+      (when throw? (throw (Exception. "rollback")))
+      (when rollback?
+        (set-rollback-only)
+        (sql/db-set-rollback-only! t)))))
 
 (defn listener [m]
   (if (:tx? m)

            [clojure.java.jdbc :as sql]))

(set-log-level! (or (System/getenv "LOG_LEVEL") :OFF))
(def cache (csh/cache "tx-test" :transactional? true))
(def queue (msg/queue "/queue/test" :durable? false))
(def local-remote-queue (msg/queue "remote" :durable? false))
(def conn (msg/context (cond-> {:host "localhost" :xa? true}

(defn verify-success []
  (is (= "kiwi" (msg/receive queue :timeout 1000)))
  (is (= "starfruit" (msg/receive local-remote-queue :timeout 1000)))
  (is (= 1 (:a tx-cache)))
  (is (= "tangerine" (:name (read-thing-from-db spec "tangerine"))))
  (is (= 1 (count-things-in-db spec))))

(defn verify-failure []
  (is (nil? (msg/receive queue :timeout 1000)))
  (is (nil? (msg/receive local-remote-queue :timeout 1000)))
  (is (nil? (:a tx-cache)))
  (is (nil? (read-thing-from-db spec "tangerine")))
  (is (= 0 (count-things-in-db spec))))

