http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/mdb-tx-send/src/main/java/org/hornetq/javaee/example/MDBMessageSendTxClientExample.java
----------------------------------------------------------------------
diff --git 
a/examples/javaee/mdb-tx-send/src/main/java/org/hornetq/javaee/example/MDBMessageSendTxClientExample.java
 
b/examples/javaee/mdb-tx-send/src/main/java/org/hornetq/javaee/example/MDBMessageSendTxClientExample.java
new file mode 100644
index 0000000..4d4d938
--- /dev/null
+++ 
b/examples/javaee/mdb-tx-send/src/main/java/org/hornetq/javaee/example/MDBMessageSendTxClientExample.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.javaee.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:andy.tay...@jboss.org";>Andy Taylor</a>
+ */
+public class MDBMessageSendTxClientExample
+{
+   public static void main(String[] args) throws Exception
+   {
+      Connection connection = null;
+      InitialContext initialContext = null;
+      try
+      {
+         //Step 1. Create an initial context to perform the JNDI lookup.
+         final Properties env = new Properties();
+
+         env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jboss.naming.remote.client.InitialContextFactory");
+
+         env.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
+
+         initialContext = new InitialContext(env);
+
+         //Step 2. Perfom a lookup on the queue
+         Queue queue = (Queue) initialContext.lookup("jms/queues/testQueue");
+
+         //Step 3. Perform a lookup on the Connection Factory
+         ConnectionFactory cf = (ConnectionFactory) 
initialContext.lookup("jms/RemoteConnectionFactory");
+
+         //Step 4.Create a JMS Connection
+         connection = cf.createConnection("guest", "password");
+
+         //Step 5. Create a JMS Session
+         Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+
+         //Step 6. Create a JMS Message Producer
+         MessageProducer producer = session.createProducer(queue);
+
+         //Step 7. Create a Text Message
+         TextMessage message = session.createTextMessage("This is a text 
message");
+
+         System.out.println("Sent message: " + message.getText());
+
+         //Step 8. Send the Message
+         producer.send(message);
+
+         //Step 15. We lookup the reply queue
+         queue = (Queue) initialContext.lookup("jms/queues/replyQueue");
+
+         //Step 16. We create a JMS message consumer
+         MessageConsumer messageConsumer = session.createConsumer(queue);
+
+         //Step 17. We start the connedction so we can receive messages
+         connection.start();
+
+         //Step 18. We receive the message and print it out
+         message = (TextMessage) messageConsumer.receive(5000);
+
+         System.out.println("message.getText() = " + message.getText());
+
+      }
+      finally
+      {
+         //Step 19. Be sure to close our JMS resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
+         if(connection != null)
+         {
+            connection.close();
+         }
+      }
+   }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/mdb-tx-send/src/main/java/org/hornetq/javaee/example/server/MDBMessageSendTxExample.java
----------------------------------------------------------------------
diff --git 
a/examples/javaee/mdb-tx-send/src/main/java/org/hornetq/javaee/example/server/MDBMessageSendTxExample.java
 
b/examples/javaee/mdb-tx-send/src/main/java/org/hornetq/javaee/example/server/MDBMessageSendTxExample.java
new file mode 100644
index 0000000..0e2cedc
--- /dev/null
+++ 
b/examples/javaee/mdb-tx-send/src/main/java/org/hornetq/javaee/example/server/MDBMessageSendTxExample.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.javaee.example.server;
+
+import org.jboss.ejb3.annotation.ResourceAdapter;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+/**
+ * @author <a href="mailto:andy.tay...@jboss.org";>Andy Taylor</a>
+ */
+@MessageDriven(name = "MDBMessageSendTxExample",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = 
"destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = 
"destination", propertyValue = "queue/testQueue")
+                     })
+public class MDBMessageSendTxExample implements MessageListener
+{
+   @Resource(mappedName = "java:/JmsXA")
+   ConnectionFactory connectionFactory;
+
+   @Resource(mappedName = "java:/queue/replyQueue")
+   Queue replyQueue;
+
+   public void onMessage(Message message)
+   {
+      Connection conn = null;
+      try
+      {
+         //Step 9. We know the client is sending a text message so we cast
+         TextMessage textMessage = (TextMessage)message;
+
+         //Step 10. get the text from the message.
+         String text = textMessage.getText();
+
+         System.out.println("message " + text);
+
+         //Step 11. we create a JMS connection
+         conn = connectionFactory.createConnection();
+
+         //Step 12. We create a JMS session
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         //Step 13. we create a producer for the reply queue
+         MessageProducer producer = sess.createProducer(replyQueue);
+
+         //Step 14. we create a message and send it
+         producer.send(sess.createTextMessage("this is a reply"));
+
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         if(conn != null)
+         {
+            try
+            {
+               conn.close();
+            }
+            catch (JMSException e)
+            {
+            }
+         }
+      }
+   }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/mdb-tx-send/src/test/java/org/hornetq/javaee/examples/MDBCMTTxSendRunnerTest.java
----------------------------------------------------------------------
diff --git 
a/examples/javaee/mdb-tx-send/src/test/java/org/hornetq/javaee/examples/MDBCMTTxSendRunnerTest.java
 
b/examples/javaee/mdb-tx-send/src/test/java/org/hornetq/javaee/examples/MDBCMTTxSendRunnerTest.java
new file mode 100644
index 0000000..9397f52
--- /dev/null
+++ 
b/examples/javaee/mdb-tx-send/src/test/java/org/hornetq/javaee/examples/MDBCMTTxSendRunnerTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.javaee.examples;
+
+import org.hornetq.javaee.example.MDBMessageSendTxClientExample;
+import org.hornetq.javaee.example.server.MDBMessageSendTxExample;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author <a href="mailto:andy.tay...@jboss.org";>Andy Taylor</a>
+ * @author Justin Bertram
+ */
+@RunAsClient
+@RunWith(Arquillian.class)
+public class MDBCMTTxSendRunnerTest
+{
+   @Deployment
+   public static Archive getDeployment()
+   {
+      final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, 
"mdb.jar");
+      ejbJar.addClass(MDBMessageSendTxExample.class);
+
+      final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");
+      war.addAsManifestResource("jboss-deployment-structure.xml", 
"jboss-deployment-structure.xml");
+      war.addAsLibrary(ejbJar);
+      System.out.println(war.toString(true));
+      return war;
+   }
+
+   @Test
+   public void runExample() throws Exception
+   {
+      MDBMessageSendTxClientExample.main(null);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/mdb-tx-send/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/javaee/mdb-tx-send/src/test/resources/arquillian.xml 
b/examples/javaee/mdb-tx-send/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..9090137
--- /dev/null
+++ b/examples/javaee/mdb-tx-send/src/test/resources/arquillian.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<arquillian xmlns="http://jboss.org/schema/arquillian";
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://jboss.org/schema/arquillian 
http://jboss.org/schema/arquillian/arquillian_1_0.xsd";>
+
+    <!-- Uncomment to have test archives exported to the file system for 
inspection.
+This feature can also be controlled using the system property 
arquillian.deploymentExportPath -->
+    <!--
+<engine>
+<property name="deploymentExportPath">target</property>
+</engine>
+-->
+
+   <defaultProtocol type="Servlet 3.0" />
+
+   <container qualifier="jboss" default="true">
+      <configuration>
+         <property name="jbossHome">${basedir}/target/jbossas-node0</property>
+         <property name="serverConfig">standalone-example.xml</property>
+         <property name="allowConnectingToRunningServer">true</property>
+         <property name="managementAddress">${node0:127.0.0.1}</property>
+      </configuration>
+   </container>
+
+    <!-- logThreshold proposed -->
+    <!--
+<container qualifier="jbossas-managed">
+<configuration>
+<property name="logThreshold">ERROR</property>
+</configuration>
+</container>
+-->
+
+</arquillian>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/mdb-tx-send/src/test/resources/jboss-deployment-structure.xml
----------------------------------------------------------------------
diff --git 
a/examples/javaee/mdb-tx-send/src/test/resources/jboss-deployment-structure.xml 
b/examples/javaee/mdb-tx-send/src/test/resources/jboss-deployment-structure.xml
new file mode 100644
index 0000000..5bd26f8
--- /dev/null
+++ 
b/examples/javaee/mdb-tx-send/src/test/resources/jboss-deployment-structure.xml
@@ -0,0 +1,7 @@
+<jboss-deployment-structure>
+   <deployment>
+      <dependencies>
+         <module name="org.hornetq"/>
+      </dependencies>
+   </deployment>
+</jboss-deployment-structure>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/pom.xml
----------------------------------------------------------------------
diff --git a/examples/javaee/pom.xml b/examples/javaee/pom.xml
new file mode 100644
index 0000000..e1a63b7
--- /dev/null
+++ b/examples/javaee/pom.xml
@@ -0,0 +1,181 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+   <modelVersion>4.0.0</modelVersion>
+
+   <parent>
+      <groupId>org.hornetq.examples</groupId>
+      <artifactId>hornetq-examples</artifactId>
+      <version>2.5.0-SNAPSHOT</version>
+   </parent>
+
+   <groupId>org.hornetq.example.javaee</groupId>
+   <artifactId>javaee-examples</artifactId>
+   <packaging>pom</packaging>
+   <name>HornetQ Java EE Examples</name>
+   <!-- Properties -->
+   <properties>
+      <!--
+      Explicitly declaring the source encoding eliminates the following
+      message: [WARNING] Using platform encoding (UTF-8 actually) to copy
+      filtered resources, i.e. build is platform dependent!
+      -->
+      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+      <jboss.home>${env.JBOSS_HOME}</jboss.home>
+
+      <!-- Note this must be consistent with the version in AS7 -->
+      <hornetq.client.version>2.5.0-SNAPSHOT</hornetq.client.version>
+
+   </properties>
+
+   <profiles>
+      <profile>
+         <id>cluster-examples</id>
+         <modules>
+            <module>mdb-remote-failover-static</module>
+         </modules>
+      </profile>
+   </profiles>
+
+   <modules>
+      <module>jca-config</module>
+      <module>mdb-bmt</module>
+      <module>mdb-cmt-setrollbackonly</module>
+      <module>mdb-cmt-setrollbackonly-with-dlq</module>
+      <module>mdb-cmt-tx-local</module>
+      <module>mdb-cmt-tx-not-supported</module>
+      <module>mdb-cmt-tx-required</module>
+      <module>jms-context-injection</module>
+      <module>mdb-message-selector</module>
+      <module>mdb-tx-send</module>
+   </modules>
+
+   <dependencyManagement>
+      <dependencies>
+         <dependency>
+            <groupId>org.jboss.arquillian</groupId>
+            <artifactId>arquillian-bom</artifactId>
+            <version>1.1.3.Final</version>
+            <scope>import</scope>
+            <type>pom</type>
+         </dependency>
+      </dependencies>
+   </dependencyManagement>
+   <dependencies>
+      <dependency>
+         <groupId>org.jboss.spec.javax.jms</groupId>
+         <artifactId>jboss-jms-api_2.0_spec</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>org.jboss.spec</groupId>
+         <artifactId>jboss-javaee-6.0</artifactId>
+         <version>1.0.0.Final</version>
+         <type>pom</type>
+         <scope>provided</scope>
+      </dependency>
+      <dependency>
+         <groupId>junit</groupId>
+         <artifactId>junit</artifactId>
+         <version>4.8.1</version>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.jboss.arquillian.junit</groupId>
+         <artifactId>arquillian-junit-container</artifactId>
+         <version>1.1.3.Final</version>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.wildfly</groupId>
+         <artifactId>wildfly-arquillian-container-managed</artifactId>
+         <version>8.0.0.Final</version>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.hornetq</groupId>
+         <artifactId>hornetq-core-client</artifactId>
+         <version>${hornetq.client.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.hornetq</groupId>
+         <artifactId>hornetq-jms-client</artifactId>
+         <version>${hornetq.client.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.hornetq</groupId>
+         <artifactId>hornetq-ra</artifactId>
+         <version>${hornetq.client.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>io.netty</groupId>
+         <artifactId>netty-all</artifactId>
+         <version>${netty.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.jboss.ejb3</groupId>
+         <artifactId>jboss-ejb3-ext-api</artifactId>
+         <version>2.1.0</version>
+      </dependency>
+      <dependency>
+         <groupId>org.jboss.arquillian.protocol</groupId>
+         <artifactId>arquillian-protocol-osgi</artifactId>
+         <version>1.0.3.Final</version>
+      </dependency>
+   </dependencies>
+
+
+   <build>
+
+      <plugins>
+
+         <!--
+             A build of target/jbossas which is shared by all modules.
+             Modules and bundles are not copied as they are read-only (see 
surefire props).
+         -->
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-resources-plugin</artifactId>
+            <executions>
+               <!-- Copy the AS into current_submodule/target/wildfly . This 
is executed recursively in submodules. -->
+               <execution>
+                  <id>as-node-0</id>
+                  <inherited>true</inherited>
+                  <phase>generate-test-resources</phase>
+                  <goals>
+                     <goal>copy-resources</goal>
+                  </goals>
+                  <configuration>
+                     
<outputDirectory>${basedir}/target/jbossas-node0</outputDirectory>
+                     <overwrite>true</overwrite>
+                     <resources>
+                        <resource>
+                           <directory>${jboss.home}</directory>
+                           <excludes>
+                              <exclude>standalone/data</exclude>
+                              <exclude>standalone/log</exclude>
+                              <exclude>standalone/tmp</exclude>
+                           </excludes>
+                        </resource>
+                        <resource>
+                           <directory>${basedir}/server</directory>
+                        </resource>
+                     </resources>
+                  </configuration>
+               </execution>
+            </executions>
+         </plugin>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-compiler-plugin</artifactId>
+         </plugin>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <version>2.12</version>
+            <configuration>
+               
<argLine>-Dlogging.configuration=file:///${user.dir}/test/config/logging.properties</argLine>
+            </configuration>
+         </plugin>
+      </plugins>
+   </build>
+</project>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/pom.xml
----------------------------------------------------------------------
diff --git a/examples/javaee/xarecovery/pom.xml 
b/examples/javaee/xarecovery/pom.xml
new file mode 100644
index 0000000..5baeb44
--- /dev/null
+++ b/examples/javaee/xarecovery/pom.xml
@@ -0,0 +1,14 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+   <modelVersion>4.0.0</modelVersion>
+
+   <parent>
+      <groupId>org.hornetq.example.javaee</groupId>
+      <artifactId>javaee-examples</artifactId>
+      <version>2.5.0-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>hornetq-javaee-xarecovery-example</artifactId>
+   <packaging>jar</packaging>
+   <name>HornetQ Java EE XA Recovery Example</name>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/readme.html
----------------------------------------------------------------------
diff --git a/examples/javaee/xarecovery/readme.html 
b/examples/javaee/xarecovery/readme.html
new file mode 100644
index 0000000..50e42db
--- /dev/null
+++ b/examples/javaee/xarecovery/readme.html
@@ -0,0 +1,201 @@
+<html>
+  <head>
+    <title>HornetQ XA Recovery Example</title>
+    <link rel="stylesheet" type="text/css" href="../../common/common.css" />
+    <link rel="stylesheet" type="text/css" href="../../common/prettify.css" />
+    <script type="text/javascript" src="../../common/prettify.js"></script>
+  </head>
+  <body onload="prettyPrint()">
+     <h1>Java EE XA Recovery Example</h1>
+     
+     <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 <a 
href="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 <a 
href="config/jndi.properties">jndi.properties</a></li>
+         </li>
+         <pre class="prettyprint">
+             <code>
+                 Properties env = new Properties();
+                 env.put(Context.URL_PKG_PREFIXES, 
"org.jboss.ejb.client.naming");
+                 initialContext = new InitialContext(env);
+             </code>
+         </pre>
+
+         <li>We look up the EJB</li>
+         <pre class="prettyprint">
+             <code>XARecoveryExampleService service = 
(XARecoveryExampleService) 
initialContext.lookup("ejb:/test//XARecoveryExampleBean!org.hornetq.javaee.example.server.XARecoveryExampleService");</code>
+         </pre>
+
+         <li>We invoke the EJB's <code>send</code> method. This method will 
send a JMS text message (with the text passed in parameter)
+             and crash the server when committing the transaction</li>
+         <pre class="prettyprint">
+             <code>String message = "This is a text message sent at " + new 
Date();
+             System.out.println("invoking the EJB service with text: " + 
message);
+             try
+             {
+                service.send(message);
+             }
+             catch (Exception e)
+             {
+                System.out.println("#########################");
+                System.out.println("The server crashed: " + e.getMessage());
+                System.out.println("#########################");
+             }</code>
+         </pre>
+         
+         <p><em>At that time, the server is crashed and is automatically 
restarted by the test runner (i.e. XARecoveryRunnerTest).</em></p>
+     </ol>
+
+     <p>Let's take a look at XARecoveryExampleStepTwo now.</p>
+
+     <ol>
+         <li>We will try to receive a message. Once the server is restarted, 
the message will be recovered and the consumer will receive it.</li>
+         <pre class="prettyprint">
+            <code>boolean received = false;
+            while (!received)
+            {
+               try
+               {
+                  Thread.sleep(15000);
+                  receiveMessage();
+                  received = true;
+               }
+               catch (Exception e)
+               {
+                  System.out.println(".");
+               }
+            }</code>
+         </pre>
+         <p>The <code>receiveMessage()</code> method contains code to receive 
a text message from the
+            JMS Queue and display it.</p>
+
+         <li>And finally, <b>always</b> remember to close your resources after 
use, in a <code>finally</code> block.</li>
+         
+         <pre class="prettyprint">
+             <code>finally
+             {
+                if (initialContext != null)
+                {
+                  initialContext.close();
+                }
+             }</code>
+          </pre>
+     </ol>
+
+     <p>Let's now take a look at the EJB example</p>
+     
+     <p>In order to crash the server while a transaction is prepared, we will 
use a <em>failing</em> <code>XAResource</code>
+         which will crash the server (calling <code>Runtime.halt()</code>) in 
its commit phase.</p>
+     <p>We will manage ourselves the transaction and its resources 
enlistment/delistment to be sure that the failing XAResource
+         will crash the server <em>after</em> the JMS XA resources is prepared 
but <em>before</em> it is committed.</p>
+
+     <ol>
+         <li>First, we create a new initial context</li>
+         <pre class="prettyprint">
+             <code>ic = new InitialContext();</code>
+        </pre>
+
+         <li>We look up the Transaction Manager</li>
+         <pre class="prettyprint">
+             <code>TransactionManager tm = 
(TransactionManager)ic.lookup("java:/TransactionManager");</code>
+        </pre>
+
+         <li>We look up the JMS <em>XA</em> Connection Factory (which is bound 
to <code>java:/JmsXA</code>)</li>
+         <pre class="prettyprint">
+             <code>XAConnectionFactory cf = 
(XAConnectionFactory)ic.lookup("java:/JmsXA");</code>
+        </pre>
+             
+         <li>We look up the JMS Queue</li>
+         <pre class="prettyprint">
+             <code>Queue queue = (Queue)ic.lookup("queue/testQueue");</code>
+        </pre>
+             
+         <li>We create a JMS XA connection, a XA session and a message 
producer for the queue</li>
+         <pre class="prettyprint">
+             <code>xaConnection = xacf.createXAConnection();
+             XASession session = xaConnection.createXASession();
+             MessageProducer messageProducer = 
session.createProducer(queue);</code>
+        </pre>
+             
+         <li>We create a <code>FailingXAResource</code>. For this example 
purpose, this XAResource implementation will
+             call <code>Runtime.halt()</code> from its <code>commit()</code> 
method</li>
+         <pre class="prettyprint">
+             <code>XAResource failingXAResource = new 
FailingXAResource();</code>
+         </pre>
+
+         <li>We begin the transaction and retrieve it from the transaction 
manager</li>
+         <pre class="prettyprint">
+             <code>tm.begin();
+             Transaction tx = tm.getTransaction();</code>
+         </pre>
+
+         <li>We enlist the failing XAResource</li>
+         <pre class="prettyprint">
+             <code>tx.enlistResource(failingXAResource);</code>
+         </pre>
+
+         <li>We enlist the <em>JMS</em> XA Resource</li>
+         <pre class="prettyprint">
+             <code>tx.enlistResource(session.getXAResource());</code>
+         </pre>
+
+         <li>We create a text message with the text passed in parameter of the 
EJB method and send it</li>
+         <pre class="prettyprint">
+             <code>TextMessage message = session.createTextMessage(text);
+             messageProducer.send(message);
+             System.out.format("Sent message: %s (%s)\n", message.getText(), 
message.getJMSMessageID());</code>
+         </pre>
+
+         <li>We delist the failing XAResource</li>
+         <pre class="prettyprint">
+             <code>tx.delistResource(failingXAResource);</code>
+         </pre>
+
+         <li>We delist the <em>JMS</em> XA Resource</li>
+         <pre class="prettyprint">
+             <code>tx.delistResource(session.getXAResource());</code>
+         </pre>
+         
+         <li>We commit the transaction</li>
+         <pre class="prettyprint">
+             <code>System.out.println("committing the tx");
+             tx.commit();</code>
+         </pre>
+         
+         <p>When the transaction is committed, it will prepare both 
XAResources and then commit them.<br />
+         <p>The failing resources will crash the server leaving the JMS XA 
Resource <em>prepared</em> but not <em>committed</em></p>
+         
+         <p>When WildFly is restarted, it will automatically trigger a 
recovery phase. During that phase, HornetQ resources will be
+         scanned and the <em>prepared</em> transaction will be recovered and 
committed. It is then possible to consume this message</p>
+  </body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/server/standalone/configuration/application-roles.properties
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/server/standalone/configuration/application-roles.properties
 
b/examples/javaee/xarecovery/server/standalone/configuration/application-roles.properties
new file mode 100644
index 0000000..0ade8fb
--- /dev/null
+++ 
b/examples/javaee/xarecovery/server/standalone/configuration/application-roles.properties
@@ -0,0 +1,22 @@
+#
+# Properties declaration of users roles for the realm 'ApplicationRealm'.
+#
+# This includes the following protocols: remote ejb, remote jndi, web, remote 
jms
+#
+# Users can be added to this properties file at any time, updates after the 
server has started
+# will be automatically detected.
+#
+# The format of this file is as follows: -
+# username=role1,role2,role3
+#
+# A utility script is provided which can be executed from the bin folder to 
add the users: -
+# - Linux
+#  bin/add-user.sh
+#
+# - Windows
+#  bin\add-user.bat
+#
+# The following illustrates how an admin user could be defined.
+#
+#admin=PowerUser,BillingAdmin,
+guest=guest

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/server/standalone/configuration/application-users.properties
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/server/standalone/configuration/application-users.properties
 
b/examples/javaee/xarecovery/server/standalone/configuration/application-users.properties
new file mode 100644
index 0000000..c52e923
--- /dev/null
+++ 
b/examples/javaee/xarecovery/server/standalone/configuration/application-users.properties
@@ -0,0 +1,24 @@
+#
+# Properties declaration of users for the realm 'ApplicationRealm' which is 
the default realm
+# for application services on a new AS 7.1 installation.
+#
+# This includes the following protocols: remote ejb, remote jndi, web, remote 
jms
+#
+# Users can be added to this properties file at any time, updates after the 
server has started
+# will be automatically detected.
+#
+# The format of this realm is as follows: -
+# username=HEX( MD5( username ':' realm ':' password))
+#
+# A utility script is provided which can be executed from the bin folder to 
add the users: -
+# - Linux
+#  bin/add-user.sh
+#
+# - Windows
+#  bin\add-user.bat
+#
+# The following illustrates how an admin user could be defined, this
+# is for illustration only and does not correspond to a usable password.
+#
+#admin=2a0923285184943425d1f53ddd58ec7a
+guest=3437456520927d113b17d471d630e0d6

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/server/standalone/configuration/logging.properties
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/server/standalone/configuration/logging.properties 
b/examples/javaee/xarecovery/server/standalone/configuration/logging.properties
new file mode 100644
index 0000000..8a011f0
--- /dev/null
+++ 
b/examples/javaee/xarecovery/server/standalone/configuration/logging.properties
@@ -0,0 +1,52 @@
+#
+# JBoss, Home of Professional Open Source.
+# Copyright 2010, Red Hat, Inc., and individual contributors
+# as indicated by the @author tags. See the copyright.txt file in the
+# distribution for a full listing of individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+
+# Additional logger names to configure (root logger is always configured)
+loggers=org.jboss.as.config
+
+# Dump system environment at boot by default
+logger.org.jboss.as.config.level=DEBUG
+
+# Root logger level
+logger.level=${jboss.boot.server.log.level:INFO}
+# Root logger handlers
+logger.handlers=FILE,CONSOLE
+
+# Console handler configuration
+handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
+handler.CONSOLE.properties=autoFlush
+handler.CONSOLE.level=${jboss.boot.server.log.console.level:INFO}
+handler.CONSOLE.autoFlush=true
+handler.CONSOLE.formatter=PATTERN
+
+# File handler configuration
+handler.FILE=org.jboss.logmanager.handlers.FileHandler
+handler.FILE.level=DEBUG
+handler.FILE.properties=autoFlush,fileName
+handler.FILE.autoFlush=true
+handler.FILE.fileName=${org.jboss.boot.log.file:boot.log}
+handler.FILE.formatter=PATTERN
+
+# Formatter pattern configuration
+formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
+formatter.PATTERN.properties=pattern
+formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/server/standalone/configuration/mgmt-users.properties
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/server/standalone/configuration/mgmt-users.properties
 
b/examples/javaee/xarecovery/server/standalone/configuration/mgmt-users.properties
new file mode 100644
index 0000000..349b004
--- /dev/null
+++ 
b/examples/javaee/xarecovery/server/standalone/configuration/mgmt-users.properties
@@ -0,0 +1,24 @@
+#
+# Properties declaration of users for the realm 'ManagementRealm' which is the 
default realm
+# for new AS 7.1 installations. Further authentication mechanism can be 
configured
+# as part of the <management /> in standalone.xml.
+#
+# Users can be added to this properties file at any time, updates after the 
server has started
+# will be automatically detected.
+#
+# By default the properties realm expects the entries to be in the format: -
+# username=HEX( MD5( username ':' realm ':' password))
+#
+# A utility script is provided which can be executed from the bin folder to 
add the users: -
+# - Linux
+#  bin/add-user.sh
+#
+# - Windows
+#  bin\add-user.bat
+
+# The following illustrates how an admin user could be defined, this
+# is for illustration only and does not correspond to a usable password.
+#
+#admin=2a0923285184943425d1f53ddd58ec7a
+admin=9d71b431e53d99563aa0dfca628c970b
+andy=dfb16391f1be1c454b5bce9822bd9df3

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/server/standalone/configuration/standalone-example.xml
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/server/standalone/configuration/standalone-example.xml
 
b/examples/javaee/xarecovery/server/standalone/configuration/standalone-example.xml
new file mode 100644
index 0000000..dbfde22
--- /dev/null
+++ 
b/examples/javaee/xarecovery/server/standalone/configuration/standalone-example.xml
@@ -0,0 +1,489 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<server xmlns="urn:jboss:domain:2.0">
+    <extensions>
+        <extension module="org.jboss.as.clustering.infinispan"/>
+        <extension module="org.jboss.as.connector"/>
+        <extension module="org.jboss.as.deployment-scanner"/>
+        <extension module="org.jboss.as.ee"/>
+        <extension module="org.jboss.as.ejb3"/>
+        <extension module="org.jboss.as.jacorb"/>
+        <extension module="org.jboss.as.jaxrs"/>
+        <extension module="org.jboss.as.jdr"/>
+        <extension module="org.jboss.as.jmx"/>
+        <extension module="org.jboss.as.jpa"/>
+        <extension module="org.jboss.as.jsf"/>
+        <extension module="org.jboss.as.jsr77"/>
+        <extension module="org.jboss.as.logging"/>
+        <extension module="org.jboss.as.mail"/>
+        <extension module="org.jboss.as.messaging"/>
+        <extension module="org.jboss.as.naming"/>
+        <extension module="org.jboss.as.pojo"/>
+        <extension module="org.jboss.as.remoting"/>
+        <extension module="org.jboss.as.sar"/>
+        <extension module="org.jboss.as.security"/>
+        <extension module="org.jboss.as.threads"/>
+        <extension module="org.jboss.as.transactions"/>
+        <extension module="org.jboss.as.webservices"/>
+        <extension module="org.jboss.as.weld"/>
+        <extension module="org.wildfly.extension.batch"/>
+        <extension module="org.wildfly.extension.io"/>
+        <extension module="org.wildfly.extension.undertow"/>
+    </extensions>
+    <management>
+        <security-realms>
+            <security-realm name="ManagementRealm">
+                <authentication>
+                    <local default-user="$local"/>
+                    <properties path="mgmt-users.properties" 
relative-to="jboss.server.config.dir"/>
+                </authentication>
+                <authorization map-groups-to-roles="false">
+                    <properties path="mgmt-groups.properties" 
relative-to="jboss.server.config.dir"/>
+                </authorization>
+            </security-realm>
+            <security-realm name="ApplicationRealm">
+                <authentication>
+                    <local default-user="$local" allowed-users="*"/>
+                    <properties path="application-users.properties" 
relative-to="jboss.server.config.dir"/>
+                </authentication>
+                <authorization>
+                    <properties path="application-roles.properties" 
relative-to="jboss.server.config.dir"/>
+                </authorization>
+            </security-realm>
+        </security-realms>
+        <audit-log>
+            <formatters>
+                <json-formatter name="json-formatter"/>
+            </formatters>
+            <handlers>
+                <file-handler name="file" formatter="json-formatter" 
relative-to="jboss.server.data.dir" path="audit-log.log"/>
+            </handlers>
+            <logger log-boot="true" log-read-only="false" enabled="false">
+                <handlers>
+                    <handler name="file"/>
+                </handlers>
+            </logger>
+        </audit-log>
+        <management-interfaces>
+            <http-interface security-realm="ManagementRealm" 
http-upgrade-enabled="true">
+                <socket-binding http="management-http"/>
+            </http-interface>
+        </management-interfaces>
+        <access-control provider="simple">
+            <role-mapping>
+                <role name="SuperUser">
+                    <include>
+                        <user name="$local"/>
+                    </include>
+                </role>
+            </role-mapping>
+        </access-control>
+    </management>
+    <profile>
+        <subsystem xmlns="urn:jboss:domain:logging:2.0">
+            <console-handler name="CONSOLE">
+                <level name="INFO"/>
+                <formatter>
+                    <named-formatter name="COLOR-PATTERN"/>
+                </formatter>
+            </console-handler>
+            <periodic-rotating-file-handler name="FILE" autoflush="true">
+                <formatter>
+                    <named-formatter name="PATTERN"/>
+                </formatter>
+                <file relative-to="jboss.server.log.dir" path="server.log"/>
+                <suffix value=".yyyy-MM-dd"/>
+                <append value="true"/>
+            </periodic-rotating-file-handler>
+            <logger category="com.arjuna">
+                <level name="WARN"/>
+            </logger>
+            <logger category="org.apache.tomcat.util.modeler">
+                <level name="WARN"/>
+            </logger>
+            <logger category="org.jboss.as.config">
+                <level name="DEBUG"/>
+            </logger>
+            <logger category="sun.rmi">
+                <level name="WARN"/>
+            </logger>
+            <logger category="jacorb">
+                <level name="WARN"/>
+            </logger>
+            <logger category="jacorb.config">
+                <level name="ERROR"/>
+            </logger>
+            <root-logger>
+                <level name="INFO"/>
+                <handlers>
+                    <handler name="CONSOLE"/>
+                    <handler name="FILE"/>
+                </handlers>
+            </root-logger>
+            <formatter name="PATTERN">
+                <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p 
[%c] (%t) %s%E%n"/>
+            </formatter>
+            <formatter name="COLOR-PATTERN">
+                <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p 
[%c] (%t) %s%E%n"/>
+            </formatter>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:batch:1.0">
+            <job-repository>
+                <in-memory/>
+            </job-repository>
+            <thread-pool>
+                <max-threads count="10"/>
+                <keepalive-time time="100" unit="milliseconds"/>
+            </thread-pool>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:datasources:2.0">
+            <datasources>
+                <datasource jndi-name="java:jboss/datasources/ExampleDS" 
pool-name="ExampleDS" enabled="true" use-java-context="true">
+                    
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
+                    <driver>h2</driver>
+                    <security>
+                        <user-name>sa</user-name>
+                        <password>sa</password>
+                    </security>
+                </datasource>
+                <drivers>
+                    <driver name="h2" module="com.h2database.h2">
+                        
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
+                    </driver>
+                </drivers>
+            </datasources>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
+            <deployment-scanner path="deployments" 
relative-to="jboss.server.base.dir" scan-interval="5000" 
runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:ee:2.0">
+            
<spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
+            
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
+            
<annotation-property-replacement>false</annotation-property-replacement>
+            <concurrent>
+                <context-services>
+                    <context-service name="default" 
jndi-name="java:jboss/ee/concurrency/context/default" 
use-transaction-setup-provider="true"/>
+                </context-services>
+                <managed-executor-services>
+                    <managed-executor-service name="default" 
jndi-name="java:jboss/ee/concurrency/executor/default" 
context-service="default" hung-task-threshold="60000" core-threads="5" 
max-threads="25" keepalive-time="5000"/>
+                </managed-executor-services>
+                <managed-scheduled-executor-services>
+                    <managed-scheduled-executor-service name="default" 
jndi-name="java:jboss/ee/concurrency/scheduler/default" 
context-service="default" hung-task-threshold="60000" core-threads="2" 
keepalive-time="3000"/>
+                </managed-scheduled-executor-services>
+                <managed-thread-factories>
+                    <managed-thread-factory name="default" 
jndi-name="java:jboss/ee/concurrency/factory/default" 
context-service="default"/>
+                </managed-thread-factories>
+            </concurrent>
+            <default-bindings 
context-service="java:jboss/ee/concurrency/context/default" 
datasource="java:jboss/datasources/ExampleDS" 
jms-connection-factory="java:jboss/DefaultJMSConnectionFactory" 
managed-executor-service="java:jboss/ee/concurrency/executor/default" 
managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default"
 managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:ejb3:2.0">
+            <session-bean>
+                <stateful default-access-timeout="5000" cache-ref="simple" 
passivation-disabled-cache-ref="simple"/>
+                <singleton default-access-timeout="5000"/>
+            </session-bean>
+            <mdb>
+                <resource-adapter-ref 
resource-adapter-name="${ejb.resource-adapter-name:hornetq-ra.rar}"/>
+                <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
+            </mdb>
+            <pools>
+                <bean-instance-pools>
+                    <!-- A sample strict max pool configuration -->
+                    <strict-max-pool name="slsb-strict-max-pool" 
max-pool-size="20" instance-acquisition-timeout="5" 
instance-acquisition-timeout-unit="MINUTES"/>
+                    <strict-max-pool name="mdb-strict-max-pool" 
max-pool-size="20" instance-acquisition-timeout="5" 
instance-acquisition-timeout-unit="MINUTES"/>
+                </bean-instance-pools>
+            </pools>
+            <caches>
+                <cache name="simple"/>
+                <cache name="distributable" aliases="passivating clustered" 
passivation-store-ref="infinispan"/>
+            </caches>
+            <passivation-stores>
+                <passivation-store name="infinispan" cache-container="ejb" 
max-size="10000"/>
+            </passivation-stores>
+            <async thread-pool-name="default"/>
+            <timer-service thread-pool-name="default" 
default-data-store="default-file-store">
+                <data-stores>
+                    <file-data-store name="default-file-store" 
path="timer-service-data" relative-to="jboss.server.data.dir"/>
+                </data-stores>
+            </timer-service>
+            <remote connector-ref="http-remoting-connector" 
thread-pool-name="default"/>
+            <thread-pools>
+                <thread-pool name="default">
+                    <max-threads count="10"/>
+                    <keepalive-time time="100" unit="milliseconds"/>
+                </thread-pool>
+            </thread-pools>
+            <iiop enable-by-default="false" use-qualified-name="false"/>
+            <default-security-domain value="other"/>
+            <default-missing-method-permissions-deny-access value="true"/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:io:1.0">
+            <worker name="default" io-threads="3"/>
+            <buffer-pool name="default" buffer-size="16384" 
buffers-per-slice="128"/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:infinispan:2.0">
+            <cache-container name="web" default-cache="passivation" 
module="org.wildfly.clustering.web.infinispan">
+                <local-cache name="passivation" batching="true">
+                    <file-store passivation="true" purge="false"/>
+                </local-cache>
+                <local-cache name="persistent" batching="true">
+                    <file-store passivation="false" purge="false"/>
+                </local-cache>
+            </cache-container>
+            <cache-container name="ejb" aliases="sfsb" 
default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan">
+                <local-cache name="passivation" batching="true">
+                    <file-store passivation="true" purge="false"/>
+                </local-cache>
+                <local-cache name="persistent" batching="true">
+                    <file-store passivation="false" purge="false"/>
+                </local-cache>
+            </cache-container>
+            <cache-container name="hibernate" default-cache="local-query" 
module="org.hibernate">
+                <local-cache name="entity">
+                    <transaction mode="NON_XA"/>
+                    <eviction strategy="LRU" max-entries="10000"/>
+                    <expiration max-idle="100000"/>
+                </local-cache>
+                <local-cache name="local-query">
+                    <transaction mode="NONE"/>
+                    <eviction strategy="LRU" max-entries="10000"/>
+                    <expiration max-idle="100000"/>
+                </local-cache>
+                <local-cache name="timestamps">
+                    <transaction mode="NONE"/>
+                    <eviction strategy="NONE"/>
+                </local-cache>
+            </cache-container>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:jacorb:1.3">
+            <orb socket-binding="jacorb" ssl-socket-binding="jacorb-ssl">
+                <initializers transactions="spec" security="identity"/>
+            </orb>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
+        <subsystem xmlns="urn:jboss:domain:jca:2.0">
+            <archive-validation enabled="true" fail-on-error="true" 
fail-on-warn="false"/>
+            <bean-validation enabled="true"/>
+            <default-workmanager>
+                <short-running-threads>
+                    <core-threads count="50"/>
+                    <queue-length count="50"/>
+                    <max-threads count="50"/>
+                    <keepalive-time time="10" unit="seconds"/>
+                </short-running-threads>
+                <long-running-threads>
+                    <core-threads count="50"/>
+                    <queue-length count="50"/>
+                    <max-threads count="50"/>
+                    <keepalive-time time="10" unit="seconds"/>
+                </long-running-threads>
+            </default-workmanager>
+            <cached-connection-manager/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:jdr:1.0"/>
+        <subsystem xmlns="urn:jboss:domain:jmx:1.3">
+            <expose-resolved-model/>
+            <expose-expression-model/>
+            <remoting-connector/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:jpa:1.1">
+            <jpa default-datasource="" 
default-extended-persistence-inheritance="DEEP"/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:jsf:1.0"/>
+        <subsystem xmlns="urn:jboss:domain:jsr77:1.0"/>
+        <subsystem xmlns="urn:jboss:domain:mail:2.0">
+            <mail-session name="default" jndi-name="java:jboss/mail/Default">
+                <smtp-server outbound-socket-binding-ref="mail-smtp"/>
+            </mail-session>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:messaging:2.0">
+            <hornetq-server>
+                <persistence-enabled>true</persistence-enabled>
+                <journal-file-size>102400</journal-file-size>
+                <journal-min-files>2</journal-min-files>
+                <connectors>
+                    <http-connector name="http-connector" 
socket-binding="http">
+                        <param key="http-upgrade-endpoint" 
value="http-acceptor"/>
+                    </http-connector>
+                    <http-connector name="http-connector-throughput" 
socket-binding="http">
+                        <param key="http-upgrade-endpoint" 
value="http-acceptor-throughput"/>
+                        <param key="batch-delay" value="50"/>
+                    </http-connector>
+                    <in-vm-connector name="in-vm" server-id="0"/>
+                </connectors>
+                <acceptors>
+                    <http-acceptor name="http-acceptor" 
http-listener="default"/>
+                    <http-acceptor name="http-acceptor-throughput" 
http-listener="default">
+                        <param key="batch-delay" value="50"/>
+                        <param key="direct-deliver" value="false"/>
+                    </http-acceptor>
+                    <in-vm-acceptor name="in-vm" server-id="0"/>
+                </acceptors>
+                <security-settings>
+                    <security-setting match="#">
+                        <permission type="send" roles="guest"/>
+                        <permission type="consume" roles="guest"/>
+                        <permission type="createNonDurableQueue" 
roles="guest"/>
+                        <permission type="deleteNonDurableQueue" 
roles="guest"/>
+                    </security-setting>
+                </security-settings>
+                <address-settings>
+                    <!--default for catch all-->
+                    <address-setting match="#">
+                        
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
+                        <expiry-address>jms.queue.ExpiryQueue</expiry-address>
+                        <redelivery-delay>0</redelivery-delay>
+                        <max-size-bytes>10485760</max-size-bytes>
+                        <address-full-policy>PAGE</address-full-policy>
+                        <page-size-bytes>2097152</page-size-bytes>
+                        
<message-counter-history-day-limit>10</message-counter-history-day-limit>
+                    </address-setting>
+                </address-settings>
+                <jms-connection-factories>
+                    <connection-factory name="InVmConnectionFactory">
+                        <connectors>
+                            <connector-ref connector-name="in-vm"/>
+                        </connectors>
+                        <entries>
+                            <entry name="java:/ConnectionFactory"/>
+                        </entries>
+                    </connection-factory>
+                    <connection-factory name="RemoteConnectionFactory">
+                        <connectors>
+                            <connector-ref connector-name="http-connector"/>
+                        </connectors>
+                        <entries>
+                            <entry 
name="java:jboss/exported/jms/RemoteConnectionFactory"/>
+                        </entries>
+                    </connection-factory>
+                    <pooled-connection-factory name="hornetq-ra">
+                        <transaction mode="xa"/>
+                        <connectors>
+                            <connector-ref connector-name="in-vm"/>
+                        </connectors>
+                        <entries>
+                            <entry name="java:/JmsXA"/>
+                            <!-- Global JNDI entry used to provide a default 
JMS Connection factory to EE application -->
+                            <entry 
name="java:jboss/DefaultJMSConnectionFactory"/>
+                        </entries>
+                    </pooled-connection-factory>
+                </jms-connection-factories>
+                <jms-destinations>
+                    <jms-queue name="testQueue">
+                        <entry name="queue/testQueue"/>
+                        <entry 
name="java:jboss/exported/jms/queues/testQueue"/>
+                    </jms-queue>
+                </jms-destinations>
+            </hornetq-server>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:naming:2.0">
+            <remote-naming/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:pojo:1.0"/>
+        <subsystem xmlns="urn:jboss:domain:remoting:2.0">
+            <endpoint worker="default"/>
+            <http-connector name="http-remoting-connector" 
connector-ref="default" security-realm="ApplicationRealm"/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:resource-adapters:2.0"/>
+        <subsystem xmlns="urn:jboss:domain:sar:1.0"/>
+        <subsystem xmlns="urn:jboss:domain:security:1.2">
+            <security-domains>
+                <security-domain name="other" cache-type="default">
+                    <authentication>
+                        <login-module code="Remoting" flag="optional">
+                            <module-option name="password-stacking" 
value="useFirstPass"/>
+                        </login-module>
+                        <login-module code="RealmDirect" flag="required">
+                            <module-option name="password-stacking" 
value="useFirstPass"/>
+                        </login-module>
+                    </authentication>
+                </security-domain>
+                <security-domain name="jboss-web-policy" cache-type="default">
+                    <authorization>
+                        <policy-module code="Delegating" flag="required"/>
+                    </authorization>
+                </security-domain>
+                <security-domain name="jboss-ejb-policy" cache-type="default">
+                    <authorization>
+                        <policy-module code="Delegating" flag="required"/>
+                    </authorization>
+                </security-domain>
+            </security-domains>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:threads:1.1"/>
+        <subsystem xmlns="urn:jboss:domain:transactions:2.0">
+            <core-environment>
+                <process-id>
+                    <uuid/>
+                </process-id>
+            </core-environment>
+            <recovery-environment socket-binding="txn-recovery-environment" 
status-socket-binding="txn-status-manager"/>
+            <coordinator-environment default-timeout="300"/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:undertow:1.0">
+            <buffer-caches>
+                <buffer-cache name="default" buffer-size="1024" 
buffers-per-region="1024" max-regions="10"/>
+            </buffer-caches>
+            <server name="default-server">
+                <http-listener name="default" socket-binding="http"/>
+                <host name="default-host" alias="localhost">
+                    <location name="/" handler="welcome-content"/>
+                    <filter-ref name="server-header"/>
+                    <filter-ref name="x-powered-by-header"/>
+                </host>
+            </server>
+            <servlet-container name="default" default-buffer-cache="default" 
stack-trace-on-error="local-only">
+                <jsp-config/>
+            </servlet-container>
+            <handlers>
+                <file name="welcome-content" 
path="${jboss.home.dir}/welcome-content" directory-listing="true"/>
+            </handlers>
+            <filters>
+                <response-header name="server-header" header-name="Server" 
header-value="Wildfly 8"/>
+                <response-header name="x-powered-by-header" 
header-name="X-Powered-By" header-value="Undertow 1"/>
+            </filters>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:webservices:1.2">
+            <modify-wsdl-address>true</modify-wsdl-address>
+            <wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>
+            <endpoint-config name="Standard-Endpoint-Config"/>
+            <endpoint-config name="Recording-Endpoint-Config">
+                <pre-handler-chain name="recording-handlers" 
protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP 
##SOAP12_HTTP_MTOM">
+                    <handler name="RecordingHandler" 
class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
+                </pre-handler-chain>
+            </endpoint-config>
+            <client-config name="Standard-Client-Config"/>
+        </subsystem>
+        <subsystem xmlns="urn:jboss:domain:weld:2.0"/>
+    </profile>
+    <interfaces>
+        <interface name="management">
+            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
+        </interface>
+        <interface name="public">
+            <inet-address value="${jboss.bind.address:127.0.0.1}"/>
+        </interface>
+        <!-- TODO - only show this if the jacorb subsystem is added  -->
+        <interface name="unsecure">
+            <!--
+              ~  Used for IIOP sockets in the standard configuration.
+              ~                  To secure JacORB you need to setup SSL 
+              -->
+            <inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
+        </interface>
+    </interfaces>
+    <socket-binding-group name="standard-sockets" default-interface="public" 
port-offset="${jboss.socket.binding.port-offset:0}">
+        <socket-binding name="management-http" interface="management" 
port="${jboss.management.http.port:9990}"/>
+        <socket-binding name="management-https" interface="management" 
port="${jboss.management.https.port:9993}"/>
+        <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
+        <socket-binding name="http" port="${jboss.http.port:8080}"/>
+        <socket-binding name="https" port="${jboss.https.port:8443}"/>
+        <socket-binding name="jacorb" interface="unsecure" port="3528"/>
+        <socket-binding name="jacorb-ssl" interface="unsecure" port="3529"/>
+        <socket-binding name="messaging-group" port="0" 
multicast-address="${jboss.messaging.group.address:231.7.7.7}" 
multicast-port="${jboss.messaging.group.port:9876}"/>
+        <socket-binding name="txn-recovery-environment" port="4712"/>
+        <socket-binding name="txn-status-manager" port="4713"/>
+        <outbound-socket-binding name="mail-smtp">
+            <remote-destination host="localhost" port="25"/>
+        </outbound-socket-binding>
+    </socket-binding-group>
+</server>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/XARecoveryExampleStepOne.java
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/XARecoveryExampleStepOne.java
 
b/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/XARecoveryExampleStepOne.java
new file mode 100644
index 0000000..997b9f8
--- /dev/null
+++ 
b/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/XARecoveryExampleStepOne.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.javaee.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Date;
+import java.util.Properties;
+
+import org.hornetq.javaee.example.server.XARecoveryExampleService;
+
+/**
+ * An example which invokes an EJB. The EJB will be involved in a
+ * transaction with a "buggy" XAResource to crash the server.
+ * When the server is restarted, the recovery manager will recover the message
+ * so that the consumer can receive it.
+ *
+ * @author <a href="mailto:andy.tay...@jboss.org";>Andy Taylor</a>
+ * @author <a href="mailto:jmes...@redhat.com";>Jeff Mesnil</a>
+ */
+public class XARecoveryExampleStepOne
+{
+   public static void main(final String[] args) throws Exception
+   {
+      InitialContext initialContext = null;
+      try
+      {
+         // Step 1. Obtain an Initial Context
+         Properties env = new Properties();
+         env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
+         initialContext = new InitialContext(env);
+
+         // Step 2. Lookup the EJB
+         XARecoveryExampleService service = (XARecoveryExampleService) 
initialContext.lookup("ejb:/test//XARecoveryExampleBean!org.hornetq.javaee.example.server.XARecoveryExampleService");
+
+         // Step 3. Invoke the send method. This will crash the server
+         String message = "This is a text message sent at " + new Date();
+         System.out.println("invoking the EJB service with text: " + message);
+         try
+         {
+            service.send(message);
+         }
+         catch (Exception e)
+         {
+            System.out.println("#########################");
+            System.out.println("The server crashed: " + e.getMessage());
+            System.out.println("#########################");
+         }
+
+         // We will try to receive a message. Once the server is restarted, 
the message will be recovered and the consumer will receive it
+      }
+      finally
+      {
+         // Step 4. Be sure to close the resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/XARecoveryExampleStepTwo.java
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/XARecoveryExampleStepTwo.java
 
b/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/XARecoveryExampleStepTwo.java
new file mode 100644
index 0000000..3c57f73
--- /dev/null
+++ 
b/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/XARecoveryExampleStepTwo.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.javaee.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Date;
+import java.util.Properties;
+
+import org.hornetq.javaee.example.server.XARecoveryExampleService;
+
+/**
+ * An example which invokes an EJB. The EJB will be involved in a
+ * transaction with a "buggy" XAResource to crash the server.
+ * When the server is restarted, the recovery manager will recover the message
+ * so that the consumer can receive it.
+ *
+ * @author <a href="mailto:andy.tay...@jboss.org";>Andy Taylor</a>
+ * @author <a href="mailto:jmes...@redhat.com";>Jeff Mesnil</a>
+ */
+public class XARecoveryExampleStepTwo
+{
+   public static void main(final String[] args) throws Exception
+   {
+      // Step 1. We will try to receive a message. Once the server is 
restarted, the message will be recovered and the consumer will receive it.
+      boolean received = false;
+      while (!received)
+      {
+         try
+         {
+            Thread.sleep(15000);
+            XARecoveryExampleStepTwo.receiveMessage();
+            received = true;
+         }
+         catch (Exception e)
+         {
+            System.out.println(".");
+         }
+      }
+   }
+
+   private static void receiveMessage() throws Exception
+   {
+      InitialContext initialContext = null;
+      Connection connection = null;
+      try
+      {
+         final Properties env = new Properties();
+
+         env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jboss.naming.remote.client.InitialContextFactory");
+
+         env.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
+
+         initialContext = new InitialContext(env);
+
+         ConnectionFactory cf = (ConnectionFactory) 
initialContext.lookup("jms/RemoteConnectionFactory");
+
+         Queue queue = (Queue) initialContext.lookup("jms/queues/testQueue");
+
+         connection = cf.createConnection("guest", "password");
+         Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+         MessageConsumer consumer = session.createConsumer(queue);
+
+         connection.start();
+
+         System.out.println("\nwaiting to receive a message...");
+         TextMessage messageReceived = (TextMessage) consumer.receive(3600 * 
1000);
+         System.out.format("Received message: %s \n\t(JMS MessageID: %s)\n",
+                           messageReceived.getText(),
+                           messageReceived.getJMSMessageID());
+      }
+      finally
+      {
+         // Step 7. Be sure to close the resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
+         if (connection != null)
+         {
+            connection.close();
+         }
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/server/XARecoveryExampleBean.java
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/server/XARecoveryExampleBean.java
 
b/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/server/XARecoveryExampleBean.java
new file mode 100644
index 0000000..55b915c
--- /dev/null
+++ 
b/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/server/XARecoveryExampleBean.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.javaee.example.server;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.TextMessage;
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.jms.XASession;
+import javax.naming.InitialContext;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * An EJB which sends a JMS message in the transaction and "pauses" while the 
transaction
+ * is prepared so that the server can be crashed in this state.
+ * The JMS message will be recovered when the server is restarted.
+ *
+ * @author <a href="mailto:andy.tay...@jboss.org";>Andy Taylor</a>
+ * @author <a href="mailto:jmes...@redhat.com";>Jeff Mesnil</a>
+ */
+@Stateless
+@Remote(XARecoveryExampleService.class)
+@TransactionManagement(TransactionManagementType.BEAN)
+public class XARecoveryExampleBean implements XARecoveryExampleService
+{
+   public void send(final String text) throws Exception
+   {
+      InitialContext ic = null;
+      XAConnection xaConnection = null;
+      try
+      {
+         // Step 1. Create the initial context
+         ic = new InitialContext();
+
+         // Step 2. Lookup the Transaction Manager
+         TransactionManager tm = 
(TransactionManager)ic.lookup("java:/TransactionManager");
+
+         // Step 3. Look up the XA Connection Factory
+         XAConnectionFactory xacf = 
(XAConnectionFactory)ic.lookup("java:/JmsXA");
+
+         // Step 4. Look up the Queue
+         Queue queue = (Queue)ic.lookup("queue/testQueue");
+
+         // Step 5. Create a XA connection, a XA session and a message 
producer for the queue
+         xaConnection = xacf.createXAConnection();
+         XASession session = xaConnection.createXASession();
+         MessageProducer messageProducer = session.createProducer(queue);
+
+         // Step 6. Create a "fake" XAResource which will crash the server in 
its commit phase
+         XAResource failingXAResource = new FailingXAResource();
+
+         // Step 7. Begin the transaction
+         tm.begin();
+         Transaction tx = tm.getTransaction();
+
+         // Step 8. Enlist the failing XAResource
+         tx.enlistResource(failingXAResource);
+
+         // Step 9. Enlist the JMS XAResource
+         tx.enlistResource(session.getXAResource());
+
+         // Step 10. Send The Text Message
+         TextMessage message = session.createTextMessage(text);
+         messageProducer.send(message);
+         System.out.format("Sent message: %s\n\t(JMS MessageID: %s)\n", 
message.getText(), message.getJMSMessageID());
+
+         // Step 12. Delist the failing XAResource
+         tx.delistResource(failingXAResource, XAResource.TMSUCCESS);
+
+         // Step 13. Delist the JMS XAResource
+         tx.delistResource(session.getXAResource(), XAResource.TMSUCCESS);
+
+         // Step 14. Commit the transaction
+         // Both XA Resources will be prepared.
+         // then the failingXAResource will crash the server in its commit 
phase
+         // and the commit method will never be called on the JMS XA Resource: 
it will
+         // be in the prepared state when the server crashes
+         System.out.println("committing the tx");
+         tx.commit();
+      }
+      finally
+      {
+         // Step 15. Be sure to close all resources!
+         if (ic != null)
+         {
+            ic.close();
+         }
+         if (xaConnection != null)
+         {
+            xaConnection.close();
+         }
+      }
+   }
+
+   /**
+    * A XAResource which crashes the server in its commit phase
+    */
+   private static class FailingXAResource implements XAResource
+   {
+
+      public void commit(final Xid arg0, final boolean arg1) throws XAException
+      {
+         System.out.println("########################");
+         System.out.println("# Crashing the server! #");
+         System.out.println("########################");
+         Runtime.getRuntime().halt(1);
+      }
+
+      public void end(final Xid arg0, final int arg1) throws XAException
+      {
+      }
+
+      public void forget(final Xid arg0) throws XAException
+      {
+      }
+
+      public int getTransactionTimeout() throws XAException
+      {
+         return 0;
+      }
+
+      public boolean isSameRM(final XAResource arg0) throws XAException
+      {
+         return false;
+      }
+
+      public int prepare(final Xid arg0) throws XAException
+      {
+
+         return XAResource.XA_OK;
+      }
+
+      public Xid[] recover(final int arg0) throws XAException
+      {
+         return null;
+      }
+
+      public void rollback(final Xid arg0) throws XAException
+      {
+      }
+
+      public boolean setTransactionTimeout(final int arg0) throws XAException
+      {
+         return false;
+      }
+
+      public void start(final Xid arg0, final int arg1) throws XAException
+      {
+      }
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/server/XARecoveryExampleService.java
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/server/XARecoveryExampleService.java
 
b/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/server/XARecoveryExampleService.java
new file mode 100644
index 0000000..82a7be8
--- /dev/null
+++ 
b/examples/javaee/xarecovery/src/main/java/org/hornetq/javaee/example/server/XARecoveryExampleService.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.javaee.example.server;
+
+/**
+ * An interface for the XARecoveryExampleBean EJB.
+ *
+ * @author <a href="mailto:jmes...@redhat.com";>Jeff Mesnil</a>
+ */
+public interface XARecoveryExampleService
+{
+   void send(String text) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/src/main/resources/jboss-ejb-client.properties
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/src/main/resources/jboss-ejb-client.properties 
b/examples/javaee/xarecovery/src/main/resources/jboss-ejb-client.properties
new file mode 100644
index 0000000..fcf57ba
--- /dev/null
+++ b/examples/javaee/xarecovery/src/main/resources/jboss-ejb-client.properties
@@ -0,0 +1,7 @@
+remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
+
+remote.connections=default
+
+remote.connection.default.host=localhost
+remote.connection.default.port = 8080
+remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/src/test/java/org/hornetq/javaee/examples/XARecoveryRunnerTest.java
----------------------------------------------------------------------
diff --git 
a/examples/javaee/xarecovery/src/test/java/org/hornetq/javaee/examples/XARecoveryRunnerTest.java
 
b/examples/javaee/xarecovery/src/test/java/org/hornetq/javaee/examples/XARecoveryRunnerTest.java
new file mode 100644
index 0000000..3dc95a6
--- /dev/null
+++ 
b/examples/javaee/xarecovery/src/test/java/org/hornetq/javaee/examples/XARecoveryRunnerTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.javaee.examples;
+
+import org.hornetq.javaee.example.XARecoveryExampleStepOne;
+import org.hornetq.javaee.example.XARecoveryExampleStepTwo;
+import org.hornetq.javaee.example.server.XARecoveryExampleBean;
+import org.hornetq.javaee.example.server.XARecoveryExampleService;
+import org.jboss.arquillian.container.test.api.*;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author <a href="mailto:andy.tay...@jboss.org";>Andy Taylor</a>
+ * @author Justin Bertram
+ */
+@RunAsClient
+@RunWith(Arquillian.class)
+public class XARecoveryRunnerTest
+{
+   @ArquillianResource
+   private ContainerController controller;
+   @ArquillianResource
+   private Deployer deployer;
+
+   @Deployment(name = "deploy", managed = false)
+   @TargetsContainer("jboss")
+   public static Archive getDeployment()
+   {
+      final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, 
"ejb.jar");
+      ejbJar.addClass(XARecoveryExampleBean.class);
+      ejbJar.addClass(XARecoveryExampleService.class);
+      System.out.println(ejbJar.toString(true));
+      return ejbJar;
+   }
+
+   @Test
+   @InSequence(0)
+   public void runExample() throws Exception
+   {
+      XARecoveryExampleStepOne.main(null);
+      try
+      {
+         controller.stop("jboss");
+      }
+      catch (Exception e)
+      {
+         //ignore
+      }
+   }
+
+   @Test
+   @InSequence(1)
+   public void stepTwo() throws Exception
+   {
+      
System.out.println("*****************************************************************************************************************************************************************");
+      controller.start("jboss");
+      XARecoveryExampleStepTwo.main(null);
+      //give the example time to run
+      Thread.sleep(10000);
+   }
+
+   @Test
+   @InSequence(-1)
+   public void startServer()
+   {
+      
System.out.println("*****************************************************************************************************************************************************************");
+      controller.start("jboss");
+      
System.out.println("*****************************************************************************************************************************************************************");
+      deployer.deploy("deploy");
+   }
+
+   @Test
+   @InSequence(2)
+   public void stopServer()
+   {
+      deployer.undeploy("deploy");
+      controller.stop("jboss");
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/xarecovery/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/javaee/xarecovery/src/test/resources/arquillian.xml 
b/examples/javaee/xarecovery/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..dc23f77
--- /dev/null
+++ b/examples/javaee/xarecovery/src/test/resources/arquillian.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<arquillian xmlns="http://jboss.org/schema/arquillian";
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://jboss.org/schema/arquillian 
http://jboss.org/schema/arquillian/arquillian_1_0.xsd";>
+
+    <!-- Uncomment to have test archives exported to the file system for 
inspection.
+This feature can also be controlled using the system property 
arquillian.deploymentExportPath -->
+    <!--
+<engine>
+<property name="deploymentExportPath">target</property>
+</engine>
+-->
+
+   <defaultProtocol type="Servlet 3.0" />
+
+   <container qualifier="jboss" default="true" mode="manual" managed="false">
+      <configuration>
+         <property name="jbossHome">${basedir}/target/jbossas-node0</property>
+         <property name="serverConfig">standalone-example.xml</property>
+         <property name="allowConnectingToRunningServer">true</property>
+         <property name="managementAddress">${node0:127.0.0.1}</property>
+      </configuration>
+   </container>
+
+   <!-- logThreshold proposed -->
+   <!--
+<container qualifier="jbossas-managed">
+<configuration>
+<property name="logThreshold">ERROR</property>
+</configuration>
+</container>
+-->
+
+</arquillian>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/README.md
----------------------------------------------------------------------
diff --git a/examples/jms/README.md b/examples/jms/README.md
new file mode 100644
index 0000000..f95a3db
--- /dev/null
+++ b/examples/jms/README.md
@@ -0,0 +1,29 @@
+Running the HornetQ Examples
+============================
+
+To run an individual example firstly cd into the example directory and run
+
+```
+mvn verify
+```
+
+If you are running against an un released version, i.e. from master branch, 
you will have to run `mvn install` on the root
+pom.xml and the example/hornetq-jms-examples-common/pom.xml first.
+
+If you want to run all the examples (except those that need to be run 
standalone) you can run `mvn verify` in the examples
+directory but before you do you will need to up the memory used by running:
+
+```
+export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
+```
+
+To run the javaee examples follow the instructions in examples/javaee/README.md
+
+### Recreating the examples
+
+If you are trying to copy the examples somewhere else and modifying them. 
Consider asking Maven to explicitly list all the dependencies:
+
+```
+# if trying to modify the 'topic' example:
+cd examples/jms/topic && mvn dependency:list
+```

Reply via email to