<p>This example will demonstrate XA recovery in WildFly with a HornetQ XA resource and a "buggy" XA resource.</p>
<p>The example application will invoke an EJB which will send a JMS message in a transaction.
The server will crash while the transaction has not been committed (it is in the prepared state).<br/>
On server restart, the transaction will be recovered and the JMS message will finally be sent.<br/>
The example application will then receive the message.<br/>
<p>The example leverages the JBoss Arquillian framework to run a WildFly instance and deploy the MDB.</p>
<h3>XA Recovery configuration</h3>
<p>In previous versions of JBoss Application Server (the precursor to WildFly) the XA recovery configuration was manual.
However, in WildFly the XA recovery configuration is completely automated.</p>
<h2>Example step-by-step</h2>
<p><i>download WildFly 8.0.0.Final from <ahref="http://wildfly.org/downloads/">here</a> and install.</i></p>
<p><i>set the JBOSS_HOME property to point to the WildFly install directory</i></p>
<p><i>type <code>mvn verify</code> from the example directory to run</i></p>
<p>The example code is composed of 3 main classes:</p>
<dl>
<dt><code>XARecoveryExampleStepOne</code> and <code>XARecoveryExampleStepTwo</code></dt>
<dd>the client application to invoke the EJB and receive the message</dd>
<dt><code>XARecoveryExampleBean</code></dt>
<dd>a Stateless EJB3 which performs all the XA logic</dd>
</dl>
<h3>Example Application</h3>
<p>Let's take a look at XARecoveryExampleStepOne first.</p>
<ol>
<li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <ahref="config/jndi.properties">jndi.properties</a></li>
<code>XARecoveryExampleService service = (XARecoveryExampleService) initialContext.lookup("ejb:/test//XARecoveryExampleBean!org.apache.activemq6.javaee.example.server.XARecoveryExampleService");</code>