0

I am trying to use immutant to manage transactions across HornetQ and mysql. As I understand the docs, to do this I must use XA transactions, because I am running a standalone app and not inside an app server.

However when I try and set :xa? for the context of my application, I get exceptions when tying to setup a listener.

(ns example
  (:require [immutant.messaging :as msg]))

(def capture (atom nil))
(let [ctx (msg/context :host "localhost" :xa? true)
      queue (msg/queue "example" :context ctx)]
  (reset! capture nil)
  (msg/listen queue (fn [m] (reset! capture m)))
  (msg/publish queue {:my :msg}))

This throws "java.lang.IllegalStateException: You can't create a child context from an XA context." from the (msg/listen) invocation. What am I doing wrong?

clumsyjedi
  • 477
  • 6
  • 15
  • Hi. So because I see the :host option, I'm assuming you're trying to connect to a HornetQ instance in a separate JVM: can you tell me about that JVM? Specifically which version of HornetQ it's running? Also, what version of Immutant? Thanks! – jcrossley3 May 27 '16 at 14:15

1 Answers1

1

I think you've discovered a bug, but in your case, I think there's a workaround: you only need that :xa? true option if your queue is remote. You can still create an XA transaction binding your HornetQ actions to MySQL in your listener handler using the immutant.transactions/transaction macro. See the docs for an example.

jcrossley3
  • 11,576
  • 4
  • 31
  • 32
  • Hi Jim, in answer yo your questions above I am using HornetQ Server version 2.5.0.SNAPSHOT (Wild Hornet, 124) and in clojure space I am pulling in the [org.immutant/immutant "2.1.4"] dependency. Alas, my production use case is a remote queue, and the use of localhost in my example is just how I'm testing it locally. Thank you very much for the bug report and patch, much appreciated. – clumsyjedi May 29 '16 at 23:13