April 29, 2014

Using XA transactions in JBoss EAP 4.3 with Websphere MQ

  I came across this problem some months ago and I realized there is no clearly documented solution. So I decided to write this post to help anyone in the same situation.

    The problem
  Using JBoss EAP 4.3 as an application server, I had also setup the IBM JMS resource adapter so that JBoss could connect to Websphere MQ. The application used 2-phase commit (XA) transactions to read data from a DB2 database and submit the corresponding messages to Websphere MQ. It was noticed however that especially during times of heavy traffic, many messages never got received by the application at the other end.
  Using the dspmqtrn control command on the MQ server revealed many in-doubt transactions. So it was obvious that transactions didn't get commited properly.

    The solution
  JCA connection factories for the Websphere MQ resource adapter are defined in a file named "wmq.jmsra-ds.xml" and located in the deploy directory of the JBoss server.
  It turns out that for XA transactions in JBoss EAP 4.3 you have to include the following inside the <tx-connection-factory> element:

<!-- Connection factory supports XA transactions flag -->
<xa-transaction />

<!-- Use a connection per transaction map -->
<track-connection-by-tx>true</track-connection-by-tx>

  This is only required for JBoss EAP 4.3. From version 5.0 onwards this is the default and it doesn't need to be defined explicitly.