You can use Atomikos and IBM MQ for JMS/XA messaging. To do so, please follow the configuration instructions outlined below.
NOTE: these instructions have been tested with IBM MQ version 184.108.40.206 for all components (queue manager, extended client, and JMS jars).
If MQ is to participate in JTA/XA transactions then you need the "Extended Transactional Client" module from IBM. This is an additional set of JMS libraries licensed separately from MQ. Contact your IBM representative if you don't have this module.
You need to add the following jars to your classpath:
The first jar file is included in the extended client installation, not in the default MQ installation. Don't forget any, or it will not work!
You need at least the following on the server:
Ask your server administrator to create these for you.
To configure Atomikos with Spring and MQ, you need to do the following:
The following shows an example Spring configuration fragment. Keep in mind that the jndi.properties should be set correctly for this to work (see your IBM documentation or ask your administrator).
<bean id="mqXaFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> <!-- set the JNDI name of the xa connection factory as configured on the server --> <property name="jndiName" value="..."/> </bean> <bean id="queue" class="org.springframework.jndi.JndiObjectFactoryBean"> <!-- set the JNDI name of the queue as configured on the server --> <property name="jndiName" value="..."/> </bean> <bean id="atomikosConnectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean" init-method="init" destroy-method="close"> <property name="xaConnectionFactory"><ref bean="mqXaFactory"/></property> <!-- IMPORTANT: the resourceName MUST contain MQSeries_XA_RMI --> <property name="uniqueResourceName" value="My_MQSeries_XA_RMI"/> </bean>
You can also choose to configure the XA connection factory programmatically. In that case, you need to create and configure an instance of
The IBM Extended Client documentation refers to the xa_open string that needs to be defined. In Java and with JMS, this is all done by the connectors so you don't need to worry about this.
The IBM documentation also refers to the xa switch structure. Once again, this is taken care of by the JMS connectors so you don't need to worry. The only thing you need to do is ensure that the resourceName of the connection factory includes the string "MQSeries_XA_RMI" as outlined above.
WebSphere MQ Bug
IMPORTANT: Due to a WebSphere MQ Java Client error (version 220.127.116.11), the JMS Listener may not close connections to MQ Series and/or may have a memory leak when trying to retrieve a connection. This may even cause your queue manager to crash. Make sure you get the WebSphere MQ 18.104.22.168 Jar Files!