I found from the application trace that my MDB was doing MQGET, MQCMIT in the listener, and MQOPEN, MQPUT, MQCLOSE and no MQCMIT in my application. Digging into this I found that the MQPUT was NO_SYNCPOINT, which was a surprise to me!
My application had session = connection.createSession(true, 1); // true = transactional. So I expected it to work.
The ejb-jar.xml had
enterprise-beans message-driven transaction-type Container ... assembly-descriptor container-transaction trans-attribute NotSupported
I changed NotSupported to Required and it worked.
The application trace for the Listener part of the MDB gave me
Operation CompCode MQRC HObj (ObjName) MQXF_XASTART 0000 - MQXF_GET MQCC_OK 0000 2 (JMSQ2 ) MQXF_XAEND 0000 - MQXF_XAPREPARE 0000 - MQXF_XACOMMIT 0000 -
The trace for the application part of the MDB gave me
Operation CompCode MQRC HObj (ObjName)
MQXF_XASTART 0000 –
MQXF_OPEN MQCC_OK 0000 2 (CP0000 )
MQXF_PUT MQCC_OK 0000 2 (CP0000 )
MQXF_CLOSE MQCC_OK 0000 2 (CP0000 )
MQXF_XAEND 0000 –
MQXF_XAPREPARE 0000 –
MQXF_XACOMMIT 0000 –
and the put options had _SYNCPOINT.
I had read documentation saying that you needed to have XAConnectionFactory instead of ConnectionFactory. I could not get this work, but found it was not needed for JMS; it may be needed for JDBC.