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?
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.