JMS Bridge Between WildFly 10 Artemis and ActiveMQ 5.14 (ONCE_AND_ONLY_ONCE Quality of Service)
<p>I'm trying to set up a JMS Bridge between Artemis (Running in WildFly 10) and ActiveMQ 5.14</p>

<p>In general the process seems to work smoothly, but unfortunately I'm getting stuck on the XA configuration that is necessary to get ONCE_AND_ONLY_ONCE QoS to work. </p>

<p>Although messages do arrive on the ActiveMQ side, I get the following error in the WildFly log:</p>

<pre><code>11:25:57,920 WARN  [org.apache.activemq.artemis.jms.bridge] (Thread-97) AMQ342009: JMS Bridge failed to send + acknowledge batch, closing JMS objects: javax.jms.IllegalStateException: Not a transacted session
at org.apache.activemq.ActiveMQSession.commit(ActiveMQSession.java:577)
at org.apache.activemq.ra.ManagedSessionProxy.commit(ManagedSessionProxy.java:108)
at org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl.sendBatchNonTransacted(JMSBridgeImpl.java:1291)
at org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl.sendBatch(JMSBridgeImpl.java:1251)
at org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl.access$1500(JMSBridgeImpl.java:75)
at org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl$BatchTimeChecker.run(JMSBridgeImpl.java:1794)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
</code></pre>

<p>My problem is similar to this one (Wildfly 10 ONCE_AND_ONLY_ONCE JMS bridge ) but unfortunately the solution doesn't totally apply to my situation, because my target is ActiveMQ 5.14.</p>

<p>From all the posts I've read it seems clear that I should ensure that the connection factories for both sides of the bridge should be configured for XA Support. On the Artemis side this seems simple enough: Simply add factory-type="XA_GENERIC" to the definition. However, I'm not able to figure out how to do this on the ActiveMQ side.</p>

<p>Here's the snippet from my standalone-full.xml that specifies my messaging subsystem:</p>

<pre><code>    &lt;subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0"&gt;
        &lt;server name="default"&gt;
            &lt;security-setting name="#"&gt;
                &lt;role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/&gt;
            &lt;/security-setting&gt;
            &lt;address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/&gt;
            &lt;http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/&gt;
            &lt;http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http"&gt;
                &lt;param name="batch-delay" value="50"/&gt;
            &lt;/http-connector&gt;
            &lt;in-vm-connector name="in-vm" server-id="0"/&gt;
            &lt;http-acceptor name="http-acceptor" http-listener="default"/&gt;
            &lt;http-acceptor name="http-acceptor-throughput" http-listener="default"&gt;
                &lt;param name="batch-delay" value="50"/&gt;
                &lt;param name="direct-deliver" value="false"/&gt;
            &lt;/http-acceptor&gt;
            &lt;in-vm-acceptor name="in-vm" server-id="0"/&gt;
            &lt;jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/&gt;
            &lt;jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/&gt;
            &lt;jms-queue name="NonBridgedTestQueue" entries="java:jboss/exported/jms/queue/nonBridgedTestQueue"/&gt;
            &lt;jms-queue name="BridgedTestQueue" entries="java:jboss/exported/jms/queue/bridgedTestQueue"/&gt;
            &lt;connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/&gt;
            &lt;connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/&gt;
            &lt;connection-factory name="InVmXAConnectionFactory" factory-type="XA_GENERIC" entries="java:/XAConnectionFactory" connectors="in-vm"/&gt;               
            &lt;pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/&gt;
        &lt;/server&gt;
        &lt;jms-bridge name="simple-jms-bridge" add-messageID-in-header="true" max-batch-time="100" max-batch-size="10" max-retries="5" failure-retry-interval="10000" quality-of-service="ONCE_AND_ONLY_ONCE"&gt;
            &lt;source destination="jboss/exported/jms/queue/bridgedTestQueue" connection-factory="java:/XAConnectionFactory"/&gt;
            &lt;target destination="jboss/activemq/queue/bridgedTestQueue" connection-factory="AMQConnectionFactory"/&gt;
        &lt;/jms-bridge&gt;
    &lt;/subsystem&gt;
</code></pre>

<p>For the ActiveMQ definition I've used a Resource Adapter, defined as follows:</p>

<pre><code>    &lt;subsystem xmlns="urn:jboss:domain:resource-adapters:4.0"&gt;
        &lt;resource-adapters&gt;
            &lt;resource-adapter id="activemq"&gt;
                &lt;archive&gt;activemq-rar-5.14.0.rar&lt;/archive&gt;
                &lt;transaction-support&gt;XATransaction&lt;/transaction-support&gt;
                &lt;config-property name="ServerUrl"&gt;tcp://localhost:61616?jms.rmIdFromConnectionId=true&lt;/config-property&gt;
                &lt;config-property name="UserName"&gt;admin&lt;/config-property&gt;
                &lt;config-property name="UseInboundSession"&gt;false&lt;/config-property&gt;
                &lt;config-property name="Password"&gt;admin&lt;/config-property&gt;
                &lt;connection-definitions&gt;
                    &lt;connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/AMQConnectionFactory" enabled="true" pool-name="AMQConnectionFactory"&gt;
                        &lt;xa-pool&gt;
                            &lt;min-pool-size&gt;1&lt;/min-pool-size&gt;
                            &lt;max-pool-size&gt;20&lt;/max-pool-size&gt;
                            &lt;prefill&gt;false&lt;/prefill&gt;
                            &lt;is-same-rm-override&gt;false&lt;/is-same-rm-override&gt;
                        &lt;/xa-pool&gt;
                    &lt;/connection-definition&gt;
                &lt;/connection-definitions&gt;
                &lt;admin-objects&gt;
                    &lt;admin-object class-name="org.apache.activemq.command.ActiveMQTopic" jndi-name="java:jboss/activemq/topic/TestTopic" use-java-context="true" pool-name="TestTopic"&gt;
                        &lt;config-property name="PhysicalName"&gt;
                            activemq/topic/TestTopic
                        &lt;/config-property&gt;
                    &lt;/admin-object&gt;
                    &lt;admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:jboss/activemq/queue/TestQueue" use-java-context="true" pool-name="TestQueue"&gt;
                        &lt;config-property name="PhysicalName"&gt;
                            activemq/queue/TestQueue
                        &lt;/config-property&gt;
                    &lt;/admin-object&gt;
                    &lt;admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:jboss/activemq/queue/bridgedTestQueue" use-java-context="true" pool-name="BridgedTestQueue"&gt;
                        &lt;config-property name="PhysicalName"&gt;
                            activemq/queue/bridgedTestQueue
                        &lt;/config-property&gt;
                    &lt;/admin-object&gt;
                &lt;/admin-objects&gt;
            &lt;/resource-adapter&gt;
        &lt;/resource-adapters&gt;
    &lt;/subsystem&gt;
</code></pre>

<p>Some pointers in the right direction will be appreciated</p>

<p>Greg</p>