Wildfly 10 jms send Message to queue as part of XA transaction
<p>I have recently had to support a colleague in verifying why some system tests are not passing in wildfly, system tests that pass consistently on weblogic and glass fish.</p>

<p>After analysing the log, it became clear the reason is related to a JMS message sent by a backed thread getting committed to a queue too soon, when the expectation was the message would be committed when the entry point Container Managed Transaction of an MDB commits. So the message is going out before the MDB that sends it is done running.</p>

<p>In weblogic, to achieve the expected behaviour, you need to make sure that when you take the connection factory given by the container , which is XA configured, you set the connection.createseesion with
 transacted = true and
  acknowledgement = session transacted.</p>

<p>In a process similar to the one depicted in this URL
<a href="http://www.mastertheboss.com/jboss-server/jboss-jms/sending-jms-messages-over-xa-with-wildfly-jboss-as" rel="nofollow noreferrer">http://www.mastertheboss.com/jboss-server/jboss-jms/sending-jms-messages-over-xa-with-wildfly-jboss-as</a>
Except in the snippet above auto acknowledge is set and the first parameter is set to false.</p>

<p>In wildly when our weblogic and glass fish configuration is used, nothing is committed and the system behaves as if the JMS message sent were to be rolled back.</p>

<p>If configuration as in the example above were to be used, instead what would happen is that the JMS message is immediately and the consumer MDB immediately launches being trigerred before the producer transaction actually ends, causing the system test to fail.</p>

<p>According to the official JMS configuration, by using a connection-pooled factory with the transaction=XA attribute, the container should immediately bind the commit of the transaction to the lifecycle of the parent transaction.</p>

<p>See official documentation bellow in particular in respect to the Java:/JmsXa connection factory.</p>

<p><a href="https://docs.jboss.org/author/display/WFLY10/Messaging+configuration" rel="nofollow noreferrer">https://docs.jboss.org/author/display/WFLY10/Messaging+configuration</a></p>

<p>My colleague was initially using a non pooled connection factory, but the injection info reference has since then been fixed. I have tried all possible combinations of parameters in the shed message, but my outcome is sitll:
Either sent too soon or never sent.</p>

<p>To conclude all the other resources are XA. Namely the oracle db is using the XA driver.</p>

<p>Can anyone confirm if in wildly the send JMS message only when parent transaction commits is working and if so how the session is being configured?</p>

<p>I will check if perhaps my colleague has not made a mistake in terms of the configuration of the connection factory used by the Men's themselves to consume messages out of the queue.but if that one is also XA... Then it is a big problem.</p>