You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by iannuz <ia...@gmail.com> on 2015/11/02 16:08:10 UTC

Tomee, MySql, ActiveMQ, XA Distributed Transactions

Hi,

I am posting this message to pre-check the feasibility of what follows
before wasting time configuring/testing it.

I'd like to know if with this platform:
- Tomee+ 1.7.2
- ActiveMQ 5.12.1
- MySql 5.7

something like this is possible or not:
<http://tomee-openejb.979440.n4.nabble.com/file/n4676680/XATransaction.png> 

In words, the flow is:
- A message reader (i.e. a MessageDriven bean) *reads from a queue* (1) and
processes one message triggering:
   - *one or more inserts/updates on a database* (2)
   - a *put of a message to another queue* (3)

(1)(2)(3) operations are all part of the same XA transaction controlled by
Tomee, so under any circumstances they either all fail or all succeed.

After a bit of searching I see that both MySql and ActiveMQ provide XA
drivers and that tomee seems to be able to create transacted resources (via
configuration in tomee.xml) made available, together with the
transactionManager, to the JEE application via JNDI.
So, on paper, it sounds feasible.. I'd just like someone with experience on
this kind of things to confirm.

Thanks!



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
Yes 

So trying to sumarrize the 3 mails ;): 

*- spring config, thanks to its wrapper, overrided some behavior where AMQ
strictly respects createSession parameters - transacted one. *
/
-------------------------------------------------
See below.
-------------------------------------------------
/
*- by default tomee uses xa activemq connections but AMQ needs a transaction
manager integration - ie the connection factory needs a resource adapter *
/
-------------------------------------------------
See below.
-------------------------------------------------
/
*- the error you have is just the usage of a XA component in a transaction
without the transacted parameter set to true *
/
-------------------------------------------------
The error I got initially was due to misconfiguration of JMS
ConnectionFactory in tomee.xml, I needed to use the resource adapter as you
pointed out.
After swicthing to your approach XA was behaving ok but I kept having a WARN
in logs from the Spring Message receiver. That was due to misconfiguration
of the Spring Message Listener with both:
<property name="sessionTransacted" value="true" />
and <property name="transactionManager" ref="transactionManager" />
while the first one should NOT be there.
Your other suggestion to go from: "session =
conn.createSession(false-->true, Session.AUTO_ACKNOWLEDGE);" in the session
used to forward the message to second ActiveMQ system does not seem to
influence the outcome of the test case, meaning that it succeeds in both
cases.. like if JTA overrides it.
-------------------------------------------------
/
*Bitronix seems to enforce some behavior wrapping AMQ - probably allowing to
use not xa impl but AMQ already impl xa so no need of it. *
/
-------------------------------------------------
Bitronix is a JTA manager that relies on the XA driver of the resources it
has to manage:
	
	<bean id="BitronixTransactionManager"
factory-method="getTransactionManager"
class="bitronix.tm.TransactionManagerServices"
		depends-on="btmConfig" destroy-method="shutdown" />
	
	<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
		<property name="autodetectTransactionManager" value="false"/>
		<property name="transactionManager" ref="BitronixTransactionManager" />
		<property name="userTransaction" ref="BitronixTransactionManager" />
	</bean>  
	<bean id="myDatasource" class="bitronix.tm.resource.jdbc.PoolingDataSource"
init-method="init" destroy-method="close">
		*<property name="className"
value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" />*
		<property name="uniqueName" value="MyDataSource" />
		<property name="maxPoolSize" value="10" />
		<property name="driverProperties">
			<props>
				<prop key="url">${database.mysql.url}</prop>
				<prop key="user">${database.mysql.user}</prop>
				<prop key="password">${database.mysql.password}</prop>
			</props>
		</property>
	</bean>
	<bean id="myIncomingConnFactory"
class="bitronix.tm.resource.jms.PoolingConnectionFactory" init-method="init"
destroy-method="close">
        *<property name="className"
value="org.apache.activemq.ActiveMQXAConnectionFactory" />*
        <property name="uniqueName" value="AMQConnectionFactoryIn" />
        <property name="maxPoolSize" value="5" />
        <property name="cacheProducersConsumers" value="false" />
        <property name="allowLocalTransactions" value="false" /> 
        <property name="driverProperties">
            <props>
                <prop key="brokerURL">${activemqIN.url}</prop>
            </props>
        </property>
    </bean>
-------------------------------------------------
/

Thanks again for your help



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676759.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Yes

So trying to sumarrize the 3 mails ;):

- spring config, thanks to its wrapper, overrided some behavior where AMQ
strictly respects createSession parameters - transacted one.
- by default tomee uses xa activemq connections but AMQ needs a transaction
manager integration - ie the connection factory needs a resource adapter
- the error you have is just the usage of a XA component in a transaction
without the transacted parameter set to true

Bitronix seems to enforce some behavior wrapping AMQ - probably allowing to
use not xa impl but AMQ already impl xa so no need of it.
Le 9 nov. 2015 05:46, "iannuz" <ia...@gmail.com> a écrit :

> Last thing to understand was why these logs when in tomee:
> -------------------------------------------
> 13:50:13,489  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
> Successfully refreshed JMS Connection
> 13:50:19,495  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
> Setup of JMS message listener invoker failed for destination
> 'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
> transaction failed to commit; nested exception is javax.j
> ms.IllegalStateException: Not a transacted session
> 13:50:19,496  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
> Successfully refreshed JMS Connection
> 13:50:25,506  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
> Setup of JMS message listener invoker failed for destination
> 'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
> transaction failed to commit; nested exception is javax.j
> ms.IllegalStateException: Not a transacted session
> 13:50:25,506  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
> Successfully refreshed JMS Connection
> 13:50:31,512  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
> Setup of JMS message listener invoker failed for destination
> 'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
> transaction failed to commit; nested exception is javax.j
> ms.IllegalStateException: Not a transacted session
> -------------------------------------------
> and why the failing test case.
>
> And the reason was that in my Spring Message listener I had both:
> <property name="sessionTransacted" value="true" />
> <property name="transactionManager" ref="transactionManager" />
>
> while sessionTransacted is not needed when a transactionManager is
> injected.
>
> THANKS A LOT FOR HELPING ME!! :)
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676753.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
Last thing to understand was why these logs when in tomee:
-------------------------------------------
13:50:13,489  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection 
13:50:19,495  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j 
ms.IllegalStateException: Not a transacted session 
13:50:19,496  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection 
13:50:25,506  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j 
ms.IllegalStateException: Not a transacted session 
13:50:25,506  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection 
13:50:31,512  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j 
ms.IllegalStateException: Not a transacted session 
-------------------------------------------
and why the failing test case.

And the reason was that in my Spring Message listener I had both:
<property name="sessionTransacted" value="true" />
<property name="transactionManager" ref="transactionManager" />

while sessionTransacted is not needed when a transactionManager is injected.

THANKS A LOT FOR HELPING ME!! :)




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676753.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
I noticed only now this:
http://tomee.apache.org/jmsconnectionfactory-config.html
Where it says:
<http://tomee-openejb.979440.n4.nabble.com/file/n4676752/xa.png> 


And I think this is the missing bit that made me NOT understand your
approach.

Now I read it differently

------------------------------------
  <Resource id="BrokerIn" type="ActiveMQResourceAdapter">
    BrokerXmlConfig =
    ServerUrl =
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0
  </Resource>

  <Resource id="BrokerOut" type="ActiveMQResourceAdapter">
    BrokerXmlConfig =
    ServerUrl =
tcp://localhost:61617?jms.redeliveryPolicy.maximumRedeliveries=0
  </Resource>

  <Resource id="jms/MyIncomingConnFactory"
type="javax.jms.ConnectionFactory">
  	ResourceAdapter = BrokerIn
  	*transactionSupport = xa* --> optional because default
  </Resource>
  <Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory">
  	ResourceAdapter = BrokerOut
  	*transactionSupport = xa* --> optional because default
  </Resource>
------------------------------------

Meaning that it is that parameter telling the ActiveMQ ra and Geronimo how
to get and deal with ActiveMQ connections and Sessions, without the
tomee.xml file to have to specify the name of the XA driver.

I think I was a bit mislead by the xa datasource configuration:
------------------------------------
  <Resource id="jdbc/myDBXAPooled" type="DataSource">
    XaDataSource myDBXA
    DataSourceCreator dbcp
    JtaManaged true
    UserName none
    Password none
    MaxWait 2000
    ValidationQuery SELECT 1 FROM SYSIBM.SYSDUMMY1
    MaxActive 15
  </Resource>
  *<Resource id="myDBXA" type="XADataSource"
class-name="org.apache.derby.jdbc.ClientXADataSource">*
    DatabaseName xaTestDB
    ServerName localhost
    PortNumber 1527
    User none
    Password none
  </Resource>
------------------------------------
where it is necessary to specify the name of the XA driver.

*Is this final interpretation of mine correct?*

Let me shape up my test case to see what I get now :)



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676752.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
I'll try with a shorter answer because long ones can be boring to read.

I said that I sort of understood the reason behind the change: "session =
conn.createSession(*false-->true*, Session.AUTO_ACKNOWLEDGE);", although
that change does not seem to affect Bitronix (which works with both).

What I don't get is why (in my sample) *you gave up using the XA ActiveMQ
driver*, in favor of the non-XA one, in a situation where 3 devices need to
participate in a *distributed transaction*.
I though that using XA Drivers for all the devices participating in an XA
transaction was mandatory and that it was not possible to mix XA and non-XA.
I also thought the real problem to be solved was "*how do I make Tomee's
transaction manager aware of my ActiveMQ !!XA!! driver?*".

If I don't misunderstand things, with your proposed solution you just went
back to the known way of configuring Tomee's TM with *non-XA* ActiveMQ
driver which seems to work with the sample with 2 devices, but that I did
not see working with 3 devices. And in both cases I get recurrent WARNINGs
in the log.

Or maybe I am completely OFF TRACK and with your approach:
/
  <Resource id="Default JMS Resource Adapter"
type="ActiveMQResourceAdapter">
    BrokerXmlConfig = 
    ServerUrl =
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0 
  </Resource>

  <Resource id="jms/MyIncomingConnFactory"
type="javax.jms.ConnectionFactory" />
  <Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory" />
/
Tomee is smart enough to use XA for ActiveMQ too.




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676751.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Wow makes a lot for a single night.

Let's try to explain my changes then:
- if you are not transacted when you create the session then you dont
participate to the rollback as expected.
- the config you dis with class-name was not using jta so same result as
previous point - this is why the ra is needed

The overall point is: bitronix config was/is not 1-1 with the one you do in
tomee + the biteonix wrapper makes amq behaving differently.

Not a transacted session means you try to use jta on a session created with
transacted=false bit a xa connection factory.

Side note: you can use bitronix in tomee if you find the ra usage overkill
or too hard.
Le 6 nov. 2015 04:54, "iannuz" <ia...@gmail.com> a écrit :

> Hi again,
>
> I have modified the test app in github so that now it runs *two concurrent
> activemq instances* in place of one.. which is the final scenario.
>
> With that scenario (where XA is really necessary) JVM+Bitronix keeps
> behaving ok *while tomee doesn't, even after applying your patch with some
> changes done in order to have two resource adapters*.
>
> I wasn't able to create the patch in GitHub as you did so I paste it here:
> ---------------------------------------------------------------
> diff --git
> a/TestXA-allEmbedded/src/main/java/com/test/MyMessageReceiver.java
> b/TestXA-allEmbedded/src/main/java/com/test/MyMessageReceiver.java
> index 6992395..e89cf4b 100644
> --- a/TestXA-allEmbedded/src/main/java/com/test/MyMessageReceiver.java
> +++ b/TestXA-allEmbedded/src/main/java/com/test/MyMessageReceiver.java
> @@ -111,7 +111,7 @@
>                 Session session = null;
>                 try {
>                         conn = forwardConnectionFactory.createConnection();
> -                       session = conn.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> +                       session = conn.createSession(true,
> Session.AUTO_ACKNOWLEDGE);
>                         MessageProducer messageProducer =
> session.createProducer(forwardQueue);
>                         TextMessage msg =
> session.createTextMessage(msgToBeSent);
>                         messageProducer.send(msg);
> diff --git a/TestXA-allEmbedded/tomee/conf/tomee.xml
> b/TestXA-allEmbedded/tomee/conf/tomee.xml
> index 65a6910..1126d53 100644
> --- a/TestXA-allEmbedded/tomee/conf/tomee.xml
> +++ b/TestXA-allEmbedded/tomee/conf/tomee.xml
> @@ -1,62 +1,65 @@
>  <?xml version="1.0" encoding="UTF-8"?>
>  <tomee>
> -
> -    <Resource id="MyAdapter" type="ActiveMQResourceAdapter">
> -        BrokerXmlConfig
> -        ServerUrl tcp://fakehost:666
> -    </Resource>
> +  <Resource id="BrokerIn" type="ActiveMQResourceAdapter">
> +    BrokerXmlConfig =
> +    ServerUrl =
> tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0
> +  </Resource>
>
> -     <Resource id="jms/MyIncomingConnFactory"
> type="javax.jms.ConnectionFactory"
> class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
> -       BrokerURL
> tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0
> -    </Resource>
> -
> -    <Resource id="jms/MyOutgoingConnFactory"
> type="javax.jms.ConnectionFactory"
> class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
> -               BrokerURL
> tcp://localhost:61617?jms.redeliveryPolicy.maximumRedeliveries=0
> -    </Resource>
> -
> -       <Resource id="jms/MyOutgoingQueue"
> class-name="org.apache.activemq.command.ActiveMQQueue">
> -               PhysicalName MY_OUTGOING_QUEUE
> -       </Resource>
> -
> -       <Resource id="jms/MyIncomingQueue"
> class-name="org.apache.activemq.command.ActiveMQQueue">
> -               PhysicalName MY_INCOMING_QUEUE
> -       </Resource>
> +  <Resource id="BrokerOut" type="ActiveMQResourceAdapter">
> +    BrokerXmlConfig =
> +    ServerUrl =
> tcp://localhost:61617?jms.redeliveryPolicy.maximumRedeliveries=0
> +  </Resource>
>
> -
> -
> -
> -       <Resource id="jdbc/myDBXAPooled" type="DataSource">
> -               XaDataSource myDBXA
> -               DataSourceCreator dbcp
> -               JtaManaged true
> -               UserName none
> -               Password none
> -               MaxWait 2000
> -               ValidationQuery SELECT 1 FROM SYSIBM.SYSDUMMY1
> -               MaxActive 15
> -       </Resource>
> -       <Resource id="myDBXA" type="XADataSource"
> class-name="org.apache.derby.jdbc.ClientXADataSource">
> -               DatabaseName xaTestDB
> -               ServerName localhost
> -               PortNumber 1527
> -               User none
> -               Password none
> -       </Resource>
> -
> +  <Resource id="jms/MyIncomingConnFactory"
> type="javax.jms.ConnectionFactory">
> +       ResourceAdapter = BrokerIn
> +  </Resource>
> +  <Resource id="jms/MyOutgoingConnFactory"
> type="javax.jms.ConnectionFactory">
> +       ResourceAdapter = BrokerOut
> +  </Resource>
> +
> +  <Resource id="jms/MyOutgoingQueue" type="javax.jms.Queue">
> +    PhysicalName = MY_OUTGOING_QUEUE
> +  </Resource>
> +
> +  <Resource id="jms/MyIncomingQueue" type="javax.jms.Queue">
> +    PhysicalName = MY_INCOMING_QUEUE
> +  </Resource>
> +
> +
> +
> +
> +  <Resource id="jdbc/myDBXAPooled" type="DataSource">
> +    XaDataSource myDBXA
> +    DataSourceCreator dbcp
> +    JtaManaged true
> +    UserName none
> +    Password none
> +    MaxWait 2000
> +    ValidationQuery SELECT 1 FROM SYSIBM.SYSDUMMY1
> +    MaxActive 15
> +  </Resource>
> +  <Resource id="myDBXA" type="XADataSource"
> class-name="org.apache.derby.jdbc.ClientXADataSource">
> +    DatabaseName xaTestDB
> +    ServerName localhost
> +    PortNumber 1527
> +    User none
> +    Password none
> +  </Resource>
> +
>  </tomee>
> ---------------------------------------------------------------
>
> Also in this case, with your patch applied, I keep getting when in tomee:
> ----------------------------------
> ...
> 13:50:13,489  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
> Successfully refreshed JMS Connection
> 13:50:19,495  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
> Setup of JMS message listener invoker failed for destination
> 'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
> transaction failed to commit; nested exception is javax.j
> ms.IllegalStateException: Not a transacted session
> 13:50:19,496  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
> Successfully refreshed JMS Connection
> 13:50:25,506  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
> Setup of JMS message listener invoker failed for destination
> 'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
> transaction failed to commit; nested exception is javax.j
> ms.IllegalStateException: Not a transacted session
> 13:50:25,506  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
> Successfully refreshed JMS Connection
> 13:50:31,512  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
> Setup of JMS message listener invoker failed for destination
> 'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
> transaction failed to commit; nested exception is javax.j
> ms.IllegalStateException: Not a transacted session
> 13:50:31,512  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
> Successfully refreshed JMS Connection
> 13:50:37,523  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
> Setup of JMS message listener invoker failed for destination
> 'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
> transaction failed to commit; nested exception is javax.j
> ms.IllegalStateException: Not a transacted session
> 13:50:37,523  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
> Successfully refreshed JMS Connection
> 13:50:43,534  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
> Setup of JMS message listener invoker failed for destination
> 'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
> transaction failed to commit; nested exception is javax.j
> ms.IllegalStateException: Not a transacted session
> ...
> ----------------------------------
>
> Pls let me know your thoughts.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676746.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
Hi again,

I have modified the test app in github so that now it runs *two concurrent
activemq instances* in place of one.. which is the final scenario.

With that scenario (where XA is really necessary) JVM+Bitronix keeps
behaving ok *while tomee doesn't, even after applying your patch with some
changes done in order to have two resource adapters*.

I wasn't able to create the patch in GitHub as you did so I paste it here:
---------------------------------------------------------------
diff --git
a/TestXA-allEmbedded/src/main/java/com/test/MyMessageReceiver.java
b/TestXA-allEmbedded/src/main/java/com/test/MyMessageReceiver.java
index 6992395..e89cf4b 100644
--- a/TestXA-allEmbedded/src/main/java/com/test/MyMessageReceiver.java
+++ b/TestXA-allEmbedded/src/main/java/com/test/MyMessageReceiver.java
@@ -111,7 +111,7 @@
 		Session session = null;
 		try {
 			conn = forwardConnectionFactory.createConnection();
-			session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+			session = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
 			MessageProducer messageProducer = session.createProducer(forwardQueue);
 			TextMessage msg = session.createTextMessage(msgToBeSent);
 			messageProducer.send(msg);
diff --git a/TestXA-allEmbedded/tomee/conf/tomee.xml
b/TestXA-allEmbedded/tomee/conf/tomee.xml
index 65a6910..1126d53 100644
--- a/TestXA-allEmbedded/tomee/conf/tomee.xml
+++ b/TestXA-allEmbedded/tomee/conf/tomee.xml
@@ -1,62 +1,65 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <tomee>
-	
-    <Resource id="MyAdapter" type="ActiveMQResourceAdapter">
-        BrokerXmlConfig
-        ServerUrl tcp://fakehost:666 
-    </Resource> 
+  <Resource id="BrokerIn" type="ActiveMQResourceAdapter">
+    BrokerXmlConfig =
+    ServerUrl =
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0
+  </Resource>
 
-     <Resource id="jms/MyIncomingConnFactory"
type="javax.jms.ConnectionFactory"
class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
-    	BrokerURL
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0 
-    </Resource>
- 
-    <Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory"
class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
-		BrokerURL
tcp://localhost:61617?jms.redeliveryPolicy.maximumRedeliveries=0
-    </Resource>
-	 
-	<Resource id="jms/MyOutgoingQueue"
class-name="org.apache.activemq.command.ActiveMQQueue">
-		PhysicalName MY_OUTGOING_QUEUE 
-	</Resource>
-	
-	<Resource id="jms/MyIncomingQueue"
class-name="org.apache.activemq.command.ActiveMQQueue">
-		PhysicalName MY_INCOMING_QUEUE 
-	</Resource>
+  <Resource id="BrokerOut" type="ActiveMQResourceAdapter">
+    BrokerXmlConfig =
+    ServerUrl =
tcp://localhost:61617?jms.redeliveryPolicy.maximumRedeliveries=0
+  </Resource>
 
-	
-	
-	
-	<Resource id="jdbc/myDBXAPooled" type="DataSource">
-		XaDataSource myDBXA
-		DataSourceCreator dbcp
-		JtaManaged true
-		UserName none
-		Password none
-		MaxWait 2000
-		ValidationQuery SELECT 1 FROM SYSIBM.SYSDUMMY1	
-		MaxActive 15
-	</Resource>	
-	<Resource id="myDBXA" type="XADataSource"
class-name="org.apache.derby.jdbc.ClientXADataSource">
-		DatabaseName xaTestDB
-		ServerName localhost
-		PortNumber 1527
-		User none
-		Password none
-	</Resource>
-	
+  <Resource id="jms/MyIncomingConnFactory"
type="javax.jms.ConnectionFactory">
+  	ResourceAdapter = BrokerIn
+  </Resource>
+  <Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory">
+  	ResourceAdapter = BrokerOut
+  </Resource>
+
+  <Resource id="jms/MyOutgoingQueue" type="javax.jms.Queue">
+    PhysicalName = MY_OUTGOING_QUEUE
+  </Resource>
+
+  <Resource id="jms/MyIncomingQueue" type="javax.jms.Queue">
+    PhysicalName = MY_INCOMING_QUEUE
+  </Resource>
+
+  
+  
+  
+  <Resource id="jdbc/myDBXAPooled" type="DataSource">
+    XaDataSource myDBXA
+    DataSourceCreator dbcp
+    JtaManaged true
+    UserName none
+    Password none
+    MaxWait 2000
+    ValidationQuery SELECT 1 FROM SYSIBM.SYSDUMMY1
+    MaxActive 15
+  </Resource>
+  <Resource id="myDBXA" type="XADataSource"
class-name="org.apache.derby.jdbc.ClientXADataSource">
+    DatabaseName xaTestDB
+    ServerName localhost
+    PortNumber 1527
+    User none
+    Password none
+  </Resource>
+
 </tomee>
---------------------------------------------------------------

Also in this case, with your patch applied, I keep getting when in tomee:
----------------------------------
...
13:50:13,489  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
13:50:19,495  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
13:50:19,496  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
13:50:25,506  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
13:50:25,506  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
13:50:31,512  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
13:50:31,512  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
13:50:37,523  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
13:50:37,523  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
13:50:43,534  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
...
----------------------------------

Pls let me know your thoughts.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676746.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
(Sorry long one :( .. but pls have a look)

Applying your patch both test cases succeed for both tomee and bitronix/jvm
*BUT I am not convinced*.

The changes you suggested are:

*(1) In MyMessageReceiver.java*
session = conn.createSession(*false-->true*, Session.AUTO_ACKNOWLEDGE);
where the parameter is "boolean transacted".
This could make sense as the solution of the problem (even alone) BUT this
one alone is not enough to make tomee work and it seemed to be ignored
anyway in the Bitronix case, maybe overwritten by JTA.

*(2) In tomee.xml*
FROM:
	
    <Resource id="MyAdapter" type="ActiveMQResourceAdapter">
        BrokerXmlConfig
        ServerUrl tcp://fakehost:666 
    </Resource> 
*
     <Resource id="jms/MyIncomingConnFactory"
type="javax.jms.ConnectionFactory"
class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
    	BrokerURL
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0 
    </Resource>
 
    <Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory"
class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
		BrokerURL tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0
    </Resource>
*	 
	<Resource id="jms/MyOutgoingQueue"
class-name="org.apache.activemq.command.ActiveMQQueue">
		PhysicalName MY_OUTGOING_QUEUE 
	</Resource>
	
	<Resource id="jms/MyIncomingQueue"
class-name="org.apache.activemq.command.ActiveMQQueue">
		PhysicalName MY_INCOMING_QUEUE 
	</Resource>

TO:
  <Resource id="Default JMS Resource Adapter"
type="ActiveMQResourceAdapter">
    BrokerXmlConfig =
    ServerUrl =
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0
  </Resource>
*
  <Resource id="jms/MyIncomingConnFactory"
type="javax.jms.ConnectionFactory" />
  <Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory" />
*
  <Resource id="jms/MyOutgoingQueue" type="javax.jms.Queue">
    PhysicalName = MY_OUTGOING_QUEUE
  </Resource>

  <Resource id="jms/MyIncomingQueue" type="javax.jms.Queue">
    PhysicalName = MY_INCOMING_QUEUE
  </Resource>

*In other words you give up using XA for active MQ BUT keep using XA for the
database :| .. and I don't get why*

In addition, when the "rollback" test case is run tomee logs this cryptic
exception:
------------------------------
11:00:22,944  INFO msgListenersTaskExecutor-1 com.test.MyMessageReceiver:50
- MESSAGE RECEIVED: Msg rollback Fri Nov 06 11:00:21 CET 2015 1446804021444
11:00:23,089 ERROR msgListenersTaskExecutor-1 com.test.MyMessageReceiver:59
- Rolling back the entire XA transaction (Message content includes the word
rollback)
r1:00:23,089  WARN msgListenersTaskExecutor-1 com.test.MyListener:936 -
Execution noofv  J0M6S,  m2e0s1s5a g1e1 :l0i0s:t2e3n eArM  foarigl.eadp,a
cahned. gneor oEnrirmoor.Htarnadnlsearc thiaosn .bmeaenna gseert..T
:jnasvaac.tliaonngI.mRpuln teinmdeREexscoeuprtcieosn
.WRAoRlNlINedG b:a cEkr rboerc aeunsdei nogf  aMsessoscaigaet icoonn tfeonrt 
XiAnRcelsuoduersc et hoer gw.oarpda crhoel.ldbearcbky
r       laite ncto.mn.ette.sNte.tMXyAMReesssoaugrecRee@c1e2i6vde0r1.6o9n;M
etsrsaangsea(cMtyiMoens swaiglelR ercoelilv ebra.cjka.v aX:A6 8e)r
n       ra tc oodreg:. s1p0r0i
Lofrrga.maepwaocrhke..jdmesr.blyi.sctleineenrt..Aabms.tXraaEcxtcMeepstsiaogne:L
iXsAt_eRnBeRrOCLoLnBtAaCiKn e:r .EdrorIonrv oekxeeLciusttiennge ra(
AXbAsRtersaocutrMcees.seangde(L)i,s tseenrevreCro nrteatiunrenre.dj
aXvAa_:R7B4R6O)L
r       AaCtK .o
A       .astp
roirngg.farpaamcehweo.rdke.rjbmys..clliisetnetn.enre.tA.bNsettrXaAcRteMseosusracgee.LtihsrtoewnXeArECxocnetpatiinoenr(.UinnkvnookwenL
iSsotuernceer)(
u       sattr
aocrtgM.easpsaacgheeL.idsetrebnye.rcCloinetnati.nneert..jNaevtaX:A6R8e4s)o
.       caet. eonrdg(.Usnpkrnionwgnf rSaomuerwcoer)k
a       mast.
loirsgt.eanpearc.hAeb.sgterraocntiMmeos.stargaenLsiasctteinoenr.Cmoanntaagienre.rT.rdaonEsxaecctutieoLniIsmtpeln.eern(dARbesstoruarccteMse(sTsraagnesLaicsttieonneIrmCpoln.tjaaivnae:r5.8j3a)v
r       6a5t1 )o
c       .aatp
aocrhge..sgperrionngifmroa.mterwaonrska.cjtmiso.nl.imsatneangeerr..ATbrsatnrsaaccttPioolnlIimnpglM.eesnsdaRgeesLoiusrtceense(rTCroanntsaaicnteiro.ndIomRpelc.ejiavveaA:n5d6E2x)e
o       taet(
Aobrsgt.raapcatcPhoel.lgienrgoMneismsoa.gterLainsstaecnteiroCno.nmtaaniangeerr..jTarvaan:s3a1c5t)i
t       Iamtp
lo.rrgo.lslpbraicnkg(fTrraamneswaocrtki.ojnmIsm.plli.sjtaevnae:r4.9A5b)s
:       aactt
Poorlgl.ianpgaMcehses.aggeerLoinsitmeon.etrrCaonnstaacitnieorn..rmeacneaigveerA.nTdrEaxnescaucttei(oAnbMsatnraagcetrPIomlplli.nrgoMlelsbsaacgke(LTirsatnesnaecrtCioonntMaainnaegre.rjIamvpal:.2j3a3v)a
o       6a5t)
(       ga.ts
porrign.gsfprraimnegwforrakm.ejwmosr.kl.itsrtaennsearc.tDieofna.ujlttaM.eJstsaaTgreaLnissatcetnieornCMoanntaagienre.rd$oARsoylnlcbMaecsks(aJgteaLTirsatnesnaecrtIinovnoMkaenra.gienrv.ojkaevLai:s1t0e4n8e)r
t       eafta
uolrtgM.esspsraignegLfirsatmeenweorrCko.nttraainnsearc.tjiaovna.:s1u1p5p0o)r
.       Aabts
torragc.tsPplraitnfgofrrmaTmreawnosrakc.tjimosn.Mlainsatgeenre.rp.rDoecfeasuslRtoMlelsbsaacgke(LAibsstternaecrtCPolnattafionremrT$rAasnysnaccMteisosnaMgaenLaigsetre.njearvIan:v8o5k3e)r
s       uant(
Doerfga.uslptrMiensgsfargaemLeiwsotrekn.etrrCaonnstaacitnieorn..jsauvpap:o1r0t4.4A)b
t       raatc
tjPalvaat.fuotrimlT.rcaonnscaucrtrieonntM.aTnhargeeard.PcooomlmEixte(cAubtsotrr.arcutnPWloartkfeorr(mTThrraenasdaPcotoiloEnxMeacnuatgoerr..jjaavvaa::1711435))

A               aatt 
ojragv.as.purtiinlg.fcroanmceuwrorrekn.tj.mTsh.rleiasdtPeonoelrE.xAebcsuttroarc$tWPoorlkleirn.grMuens(sTahgreeLaidsPtoeonleErxCeocnuttaoirn.ejra.vrae:c6e1i5v)e
n       daEtx
ejcauvtae.(lAabnsgt.rTahcrtePaodl.lriunng(MTehsrseaagde.Ljiasvtae:n7e2r4C)o
tainer.java:247)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1150)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1044)
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
*Caused by: org.apache.derby.client.am.SqlException: Error executing a
XAResource.end(), server returned XA_RBROLLBACK.
        at
org.apache.derby.client.net.NetXAResource.xaRetValErrorAccumSQL(Unknown
Source)
        ... 14 more*
------------------------------
Which is a WARN and which could simply be the Derby XA driver informing you
that he was asked to rollback.
*But the same driver doesn't give any warning with the full XA Bitronix
solution* (which only gives the WARN about the onMessage having ended with
RuntimeException:
------------------------------
11:15:57,743  INFO msgListenersTaskExecutor-1 com.test.MyMessageReceiver:50
- MESSAGE RECEIVED: Msg rollback Fri Nov 06 11:15:57 CET 2015 1446804957489
11:15:57,778 ERROR msgListenersTaskExecutor-1 com.test.MyMessageReceiver:59
- Rolling back the entire XA transaction (Message content includes the word
rollback)
11:15:57,779  WARN msgListenersTaskExecutor-1 com.test.MyListener:936 -
Execution of JMS message listener failed, and no ErrorHandler has been set.
java.lang.RuntimeException: Rolled back because of Message content includes
the word rollback
        at com.test.MyMessageReceiver.onMessage(MyMessageReceiver.java:68)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:746)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:684)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:651)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:315)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:233)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1150)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1044)
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
Running
------------------------------

So *what's the logical explanation behind this change?*
- tomee + activemq *XA* does not work in tomee (*but it does in bitronix*)
so we give up xa driver and are lucky anyway with non xa (??)
And then I am wondering: what about my initial scenario of having 2 ActiveMQ
systems one for incoming queue and one for outgoing, will non-XA work in
that case too? (And this is something I can test).

I also noticed that in the logs of tomee (with your patch) I keep having:
-----------------------------------
...
11:13:07,692  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:13,710  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:13,711  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:19,723  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:19,724  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:25,738  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:25,738  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:31,748  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:31,749  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:37,766  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:37,767  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:43,780  WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:43,780  INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
...
-----------------------------------

What is your opinion about my comments and doubts?





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676745.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

thanks a lot for the test, really helps to understand your case and what
you were trying to do.

Here is what I changed, let me know if it helps:
https://gist.github.com/rmannibucau/b014cb1cd4625c03019d


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-11-05 14:57 GMT-08:00 iannuz <ia...@gmail.com>:

> Hi again,
>
> I repackaged the *test application* so that now *it does not require any
> environment setup*.
> Only thing is that, in order to achieve that, I had to add also the
> possibility to use Derby in place of MySql.
> I also use only one instance of ActiveMQ (in place of two used before) but
> the problem seems to show up anyway.
>
> https://github.com/iannuz/TestXA-allEmbedded
>
> It should only be enough to download it and follow the instructions in
> README.txt
> If there are issues let me know.
>
> It still gives the possibility to run the same test case on the same code
> either in "tomee" or java-"standalone/bitronix".
> In second case the test case is successful in first case there are issues
> in
> the "rollback" situation.
>
> I hope that the not correct behavior in tomee comes from bad settings I did
> somewhere (maybe in
>
> https://github.com/iannuz/TestXA-allEmbedded/blob/master/TestXA-allEmbedded/tomee/conf/tomee.xml
> ).
>
> Once all the processes are up the activemq UI
> (http://localhost:8161/admin/queues.jsp) should be available for
> monitoring
> the queues and for doing also manual testing.
>
> Messages put into "MY_INCOMING_QUEUE" that contain the text "/commit/" will
> be stored in db and forwarded to "MY_OUTGOING_QUEUE", those that contain
> the
> text "/rollback/" will trigger an insert in the DB, a put in the
> "MY_OUTGOING_QUEUE" and then a rollback. The rollback should put back the
> message into "MY_INCOMING_QUEUE", but since msg redelivery is set to 0 then
> the same message will end up in "DLQ.MY_INCOMING_QUEUE". This is exactly
> what the automated test case triggers and checks.
>
> Hopefully the effort I have done will allow you to reproduce the problem in
> just a few minutes.
>
> Thanks
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676743.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
Hi again,

I repackaged the *test application* so that now *it does not require any
environment setup*.
Only thing is that, in order to achieve that, I had to add also the
possibility to use Derby in place of MySql.
I also use only one instance of ActiveMQ (in place of two used before) but
the problem seems to show up anyway.

https://github.com/iannuz/TestXA-allEmbedded

It should only be enough to download it and follow the instructions in
README.txt
If there are issues let me know.

It still gives the possibility to run the same test case on the same code
either in "tomee" or java-"standalone/bitronix".
In second case the test case is successful in first case there are issues in
the "rollback" situation.

I hope that the not correct behavior in tomee comes from bad settings I did
somewhere (maybe in
https://github.com/iannuz/TestXA-allEmbedded/blob/master/TestXA-allEmbedded/tomee/conf/tomee.xml).

Once all the processes are up the activemq UI
(http://localhost:8161/admin/queues.jsp) should be available for monitoring
the queues and for doing also manual testing.

Messages put into "MY_INCOMING_QUEUE" that contain the text "/commit/" will
be stored in db and forwarded to "MY_OUTGOING_QUEUE", those that contain the
text "/rollback/" will trigger an insert in the DB, a put in the
"MY_OUTGOING_QUEUE" and then a rollback. The rollback should put back the
message into "MY_INCOMING_QUEUE", but since msg redelivery is set to 0 then
the same message will end up in "DLQ.MY_INCOMING_QUEUE". This is exactly
what the automated test case triggers and checks.

Hopefully the effort I have done will allow you to reproduce the problem in
just a few minutes.

Thanks





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676743.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
As a quick thing I have downloaded *ActiveMQ 5.10.0* (same version embedded
in tomee 1.7.2) and used that one in place of 5.12.1 I was using before.
But with same result: working ok with "java-standalone/bitronix" but not
rolling back jms stuff when run in "tomee".

*I will now try to do what you suggest, I am not familiar with arquillian
but will have the chance to learn it.*

In any case even if it will work with the embedded activemq that is not the
situation I need.
The solution I need to migrate to tomee/activemq/mysql has several modules
running in their own tomee instance and sharing two activemq systems and
same mysql db instance.

>From what I have read and heard it seemed that also my approach should
work.. but, unless I do something wrong in my test app, it doesn't.




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676726.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by Romain Manni-Bucau <rm...@gmail.com>.
seems working updating it to use tomee embedded broker, if you have time to
update your sample to fail just running a test (using arquillian to
start/stop tomee + start 2 AMQs brokers in the test ) we can investigate
further but I dont have time to setup all this infra ATM.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-11-04 14:52 GMT-08:00 iannuz <ia...@gmail.com>:

> Hi,
>
> I have completed the test application and committed to:
> https://github.com/iannuz/TestDistributedXA-Spring.git
>
> It implements what is in the picture in my first message of this post in
> two
> ways:
> 1- java stand-alone app with bitronix as JTA trans manager
> 2- webapp running in tomee
>
> First one works as expected both in commit and rollback case.
> Second one commits all three operations in case of success BUT it only
> rolls
> back mysql operation in case of failure, while the two activemq ones are
> committed anyway.
>
> It could either be:
> - wrong settings in my tomee.xml (especially queue connection factories) or
> somewhere else
> - a bug??
>
> I already spent quite much time fighting with the thing and googling for
> possible solutions.
>
> It would be great to hear your opinion on this and, once again, advanced
> apologies if it turns out to be a mistake on my side :(
>
> Please see the
>
> https://github.com/iannuz/TestDistributedXA-Spring/blob/master/TestDistributedXA-Spring/README.txt
> for a detailed description of how to use the test app.
>
> Note: I am aware of the pending bug on mysql+XA+pooling in tomee 1.7.x:
> connections leak if MaxIdle is set. BUT I decided to ignore that for a
> while
> and test my use case further.
>
> Thanks!
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676724.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
Hi,

I have completed the test application and committed to:
https://github.com/iannuz/TestDistributedXA-Spring.git

It implements what is in the picture in my first message of this post in two
ways:
1- java stand-alone app with bitronix as JTA trans manager
2- webapp running in tomee

First one works as expected both in commit and rollback case.
Second one commits all three operations in case of success BUT it only rolls
back mysql operation in case of failure, while the two activemq ones are
committed anyway.

It could either be:
- wrong settings in my tomee.xml (especially queue connection factories) or
somewhere else
- a bug??

I already spent quite much time fighting with the thing and googling for
possible solutions.

It would be great to hear your opinion on this and, once again, advanced
apologies if it turns out to be a mistake on my side :(

Please see the
https://github.com/iannuz/TestDistributedXA-Spring/blob/master/TestDistributedXA-Spring/README.txt
for a detailed description of how to use the test app.

Note: I am aware of the pending bug on mysql+XA+pooling in tomee 1.7.x:
connections leak if MaxIdle is set. BUT I decided to ignore that for a while
and test my use case further.

Thanks!




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676724.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
Sorry, previous problem solved..

    <Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory"
class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
		BrokerURL tcp://10.254.187.69:61616
    </Resource>

seems to be the correct way of doing it with
"org.apache.activemq.ActiveMQXAConnectionFactory", what I was doing
previously seems to work only with non XA connection factory.

Sorry for the noise.. now I am fighting with a new problem.. but will try
some more before sharing with you.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676719.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by iannuz <ia...@gmail.com>.
Ok.. I am now trying to test that with a simple webapp.

But already struggling.

I have:
-------------------------------
tomee.xml

<?xml version="1.0" encoding="UTF-8"?>
<tomee>

    <Resource id="MyOutgoingResourceAdapter" type="ActiveMQResourceAdapter">
        BrokerXmlConfig =
        *ServerUrl       =  tcp://10.254.187.69:61616* 
    </Resource>

    <Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory"
class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
    	ResourceAdapter MyOutgoingResourceAdapter
    	JtaManaged true
    </Resource>

    <Resource id="MyIncomingResourceAdapter" type="ActiveMQResourceAdapter">
        BrokerXmlConfig =
        *ServerUrl       =  tcp://10.254.187.69:61616*
    </Resource>

    <Resource id="jms/MyIncomingConnFactory"
type="javax.jms.ConnectionFactory"
class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
    	ResourceAdapter MyIncomingResourceAdapter
    	JtaManaged true
    </Resource>
    
	 
	<Resource id="jms/MyOutgoingQueue"
class-name="org.apache.activemq.command.ActiveMQQueue">
		PhysicalName MY_OUTGOING_QUEUE 
	</Resource>
	
	<Resource id="jms/MyIncomingQueue"
class-name="org.apache.activemq.command.ActiveMQQueue">
		PhysicalName MY_INCOMING_QUEUE 
	</Resource>
</tomee>

-------------------------------

But despite this I see:

-------------------------------
catalina.log

nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Server version:        Apache Tomcat (TomEE)/7.0.62 (1.7.2)
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Server built:          May 7 2015 17:14:55 UTC
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Server number:         7.0.62.0
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: OS Name:               Windows 7
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: OS Version:            6.1
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Architecture:          amd64
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Java Home:             c:\Program Files\Java\jdk1.7.0_25\jre
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: JVM Version:           1.7.0_25-b17
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: JVM Vendor:            Oracle Corporation
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: CATALINA_BASE:        
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: CATALINA_HOME:        
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument: -XX:+HeapDumpOnOutOfMemoryError
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Dopenejb.session.manager=org.apache.tomee.catalina.session.QuickSessionManager
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument: -Dtomee.remote.support=true
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument: -Dopenejb.system.apps=false
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument: -Dfoo=bar
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Djava.util.logging.config.file=E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\conf\logging.properties
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-javaagent:E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\lib\openejb-javaagent.jar
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Djava.io.tmpdir=E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\temp
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Djava.endorsed.dirs=E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\endorsed
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Dcatalina.base=E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Dcatalina.home=E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Dcatalina.ext.dirs=E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\lib
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument:
-Dorg.apache.tomcat.util.http.ServerCookie.ALLOW_HTTP_SEPARATORS_IN_V0=true
nov 04, 2015 10:10:45 AM org.apache.catalina.startup.VersionLoggerListener
log
INFO: Command line argument: -ea
nov 04, 2015 10:10:45 AM org.apache.catalina.core.AprLifecycleListener
lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal
performance in production environments was not found on the
java.library.path: c:\Program
Files\Java\jdk1.7.0_25\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\Program
Files (x86)\PC Connectivity
Solution\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\DevTools\Maven\apache-maven-3.0.4\bin;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files\TortoiseSVN\bin;C:\Program Files (x86)\Google\Hangouts Plugin for
Microsoft Outlook\;C:\Program
Files\Java\jdk1.6.0_38\bin;C:\tools\SlikSvn\bin;C:\devtools\MySQL\MySQLUtilities\;C:\devtools\MySQL\MySQLUtilities\Doctrine
extensions for PHP\;C:\tools\UltraEdit_v20\;.
nov 04, 2015 10:10:45 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
nov 04, 2015 10:10:45 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
nov 04, 2015 10:10:45 AM org.apache.openejb.util.OptionsLog info
INFO: Using 'tomee.remote.support=true'
nov 04, 2015 10:10:45 AM org.apache.openejb.util.OptionsLog info
INFO: Using
'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO:
********************************************************************************
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO: OpenEJB http://tomee.apache.org/
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO: Startup: Wed Nov 04 10:10:46 CET 2015
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO: Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO: Version: 4.7.2
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO: Build date: 20150517
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO: Build time: 10:10
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO:
********************************************************************************
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO: openejb.home =
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee
nov 04, 2015 10:10:46 AM org.apache.openejb.OpenEJB$Instance <init>
INFO: openejb.base =
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee
nov 04, 2015 10:10:46 AM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFO: Created new singletonService
org.apache.openejb.cdi.ThreadSingletonServiceImpl@64d0dd5c
nov 04, 2015 10:10:46 AM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFO: Succeeded in installing singleton service
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory init
INFO: openejb configuration file is
'E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\conf\tomee.xml'
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=Tomcat Security Service, type=SecurityService,
provider-id=Tomcat Security Service)
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory
configureService
*INFO: Configuring Service(id=MyOutgoingResourceAdapter, type=Resource,
provider-id=Default JMS Resource Adapter)*
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=jms/MyOutgoingConnFactory, type=Resource,
provider-id=jms/MyOutgoingConnFactory)
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory
configureService
*INFO: Configuring Service(id=MyIncomingResourceAdapter, type=Resource,
provider-id=Default JMS Resource Adapter)*
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=jms/MyIncomingConnFactory, type=Resource,
provider-id=jms/MyIncomingConnFactory)
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=jms/MyOutgoingQueue, type=Resource,
provider-id=jms/MyOutgoingQueue)
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=jms/MyIncomingQueue, type=Resource,
provider-id=jms/MyIncomingQueue)
nov 04, 2015 10:10:46 AM org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.system.apps=false'
nov 04, 2015 10:10:46 AM org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.deployments.classpath=false'
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating TransactionManager(id=Default Transaction Manager)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating SecurityService(id=Tomcat Security Service)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=MyOutgoingResourceAdapter)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
doCreateResource
INFO: Thread pool size for 'MyOutgoingResourceAdapter' is (30)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=MyIncomingResourceAdapter)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
doCreateResource
INFO: Thread pool size for 'MyIncomingResourceAdapter' is (30)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=jms/MyOutgoingQueue)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=jms/MyIncomingQueue)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=jms/MyOutgoingConnFactory)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=jms/MyIncomingConnFactory)
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
unusedProperty
WARNING: Property "ServiceId" not supported by "jms/MyOutgoingQueue"
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
unusedProperty
WARNING: Property "ServiceId" not supported by "jms/MyIncomingQueue"
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
unusedProperty
WARNING: Property "JtaManaged" not supported by "jms/MyOutgoingConnFactory"
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
unusedProperty
WARNING: Property "ServiceId" not supported by "jms/MyOutgoingConnFactory"
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
unusedProperty
WARNING: Property "JtaManaged" not supported by "jms/MyIncomingConnFactory"
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
unusedProperty
WARNING: Property "ServiceId" not supported by "jms/MyIncomingConnFactory"
nov 04, 2015 10:10:46 AM org.apache.openejb.server.ServiceManager initServer
INFO: Creating ServerService(id=cxf)
nov 04, 2015 10:10:46 AM org.apache.openejb.server.ServiceManager initServer
INFO: Creating ServerService(id=cxf-rs)
nov 04, 2015 10:10:46 AM org.apache.openejb.server.SimpleServiceManager
start
INFO:   ** Bound Services **
nov 04, 2015 10:10:46 AM org.apache.openejb.server.SimpleServiceManager
printRow
INFO:   NAME                 IP              PORT  
nov 04, 2015 10:10:46 AM org.apache.openejb.server.SimpleServiceManager
start
INFO: -------
nov 04, 2015 10:10:46 AM org.apache.openejb.server.SimpleServiceManager
start
INFO: Ready!
nov 04, 2015 10:10:46 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1835 ms
nov 04, 2015 10:10:46 AM
org.apache.tomee.catalina.OpenEJBNamingContextListener bindResource
INFO: Importing a Tomcat Resource with id 'UserDatabase' of type
'org.apache.catalina.UserDatabase'.
nov 04, 2015 10:10:46 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=UserDatabase)
nov 04, 2015 10:10:46 AM org.apache.catalina.core.StandardService
startInternal
INFO: Starting service Catalina
nov 04, 2015 10:10:46 AM org.apache.catalina.core.StandardEngine
startInternal
INFO: Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.62 (1.7.2)
nov 04, 2015 10:10:46 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\webapps\TestDistributedXA-Spring-0.0.1-SNAPSHOT.war
nov 04, 2015 10:10:46 AM org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: ------------------------- localhost ->
/TestDistributedXA-Spring-0.0.1-SNAPSHOT
nov 04, 2015 10:10:46 AM org.apache.openejb.util.JarExtractor extract
INFO: Extracting jar:
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\webapps\TestDistributedXA-Spring-0.0.1-SNAPSHOT.war
nov 04, 2015 10:10:46 AM org.apache.openejb.util.JarExtractor extract
INFO: Extracted path:
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\webapps\TestDistributedXA-Spring-0.0.1-SNAPSHOT
nov 04, 2015 10:10:46 AM org.apache.openejb.util.OptionsLog info
INFO: Using
'openejb.session.manager=org.apache.tomee.catalina.session.QuickSessionManager'
nov 04, 2015 10:10:46 AM org.apache.openejb.config.ConfigurationFactory
configureApplication
INFO: Configuring enterprise application:
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\webapps\TestDistributedXA-Spring-0.0.1-SNAPSHOT
nov 04, 2015 10:10:47 AM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=Default JDBC Database, type=Resource,
provider-id=Default JDBC Database)
nov 04, 2015 10:10:47 AM org.apache.openejb.config.AutoConfig
logAutoCreateResource
INFO: Auto-creating a Resource with id 'Default JDBC Database' of type
'javax.sql.DataSource for 'TestDistributedXA-Spring-0.0.1-SNAPSHOT'.
nov 04, 2015 10:10:47 AM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=Default JDBC Database)
nov 04, 2015 10:10:47 AM
org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource readOnly
INFO: Disabling testOnBorrow since no validation query is provided
nov 04, 2015 10:10:47 AM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application
"E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\webapps\TestDistributedXA-Spring-0.0.1-SNAPSHOT"
loaded.
nov 04, 2015 10:10:47 AM org.apache.openejb.assembler.classic.Assembler
createApplication
INFO: Assembling app:
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\webapps\TestDistributedXA-Spring-0.0.1-SNAPSHOT
nov 04, 2015 10:10:47 AM org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance():
org.apache.openejb.cdi.ThreadSingletonServiceImpl@64d0dd5c
nov 04, 2015 10:10:47 AM org.apache.openejb.cdi.OpenEJBLifecycle
startApplication
INFO: OpenWebBeans Container is starting...
nov 04, 2015 10:10:47 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
nov 04, 2015 10:10:47 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
nov 04, 2015 10:10:47 AM org.apache.webbeans.config.BeansDeployer
validateInjectionPoints
INFO: All injection points were validated successfully.
nov 04, 2015 10:10:47 AM org.apache.openejb.cdi.OpenEJBLifecycle
startApplication
INFO: OpenWebBeans Container has started, it took 86 ms.
nov 04, 2015 10:10:47 AM org.apache.openejb.assembler.classic.Assembler
createApplication
INFO: Deployed
Application(path=E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\webapps\TestDistributedXA-Spring-0.0.1-SNAPSHOT)
nov 04, 2015 10:10:47 AM
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing
org.springframework.context.support.ClassPathXmlApplicationContext@6686dbbe:
startup date [Wed Nov 04 10:10:47 CET 2015]; root of context hierarchy
nov 04, 2015 10:10:47 AM
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[SpringConfig.xml]
nov 04, 2015 10:10:49 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@2198ffb6:
defining beans
[myOutgoingConnFactory,myIncomingConnFactory,myOutgoingQueue,myIncomingQueue,transactionManager,messageListener,myMessageProcessor,msgListenersTaskExecutor];
root of factory hierarchy
nov 04, 2015 10:10:49 AM
org.springframework.transaction.jta.JtaTransactionManager
checkUserTransactionAndTransactionManager
INFO: Using JTA UserTransaction:
org.apache.geronimo.transaction.manager.GeronimoTransactionManager@75449995
nov 04, 2015 10:10:49 AM
org.springframework.transaction.jta.JtaTransactionManager
checkUserTransactionAndTransactionManager
INFO: Using JTA TransactionManager:
org.apache.geronimo.transaction.manager.GeronimoTransactionManager@75449995
nov 04, 2015 10:10:49 AM
org.springframework.transaction.jta.JtaTransactionManager
initTransactionSynchronizationRegistry
INFO: Using JTA TransactionSynchronizationRegistry:
org.apache.geronimo.transaction.manager.GeronimoTransactionManager@75449995
nov 04, 2015 10:10:49 AM
org.springframework.scheduling.concurrent.ExecutorConfigurationSupport
initialize
INFO: Initializing ExecutorService  'msgListenersTaskExecutor'
nov 04, 2015 10:10:49 AM
org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup
start
INFO: Starting beans in phase 2147483647
nov 04, 2015 10:10:49 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive
E:\SirtomauWorkspace\mysql-src\TestDistributedXA-Spring\target\apache-tomee\webapps\TestDistributedXA-Spring-0.0.1-SNAPSHOT.war
has finished in 3,091 ms
nov 04, 2015 10:10:49 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
nov 04, 2015 10:10:49 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
nov 04, 2015 10:10:49 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3176 ms
nov 04, 2015 10:11:05 AM
org.apache.activemq.transport.failover.FailoverTransport doReconnect
*WARNING: Failed to connect to [tcp://localhost:61616] after: 10 attempt(s)
continuing to retry.*

-------------------------------

It seems to be ignoring my settings and *connecting to localhost rather than
the IP I want*, I spent quite much time trying to understand why (to avoid
bothering you) but no luck :(

Those resources are used via Spring which is initialized when the webapp
bootstraps:

-------------------------------
SpringContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jee="http://www.springframework.org/schema/jee"
			xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-4.2.xsd">
    
*
    <jee:jndi-lookup jndi-name="jms/MyOutgoingConnFactory"
id="myOutgoingConnFactory" resource-ref="true" />
    <jee:jndi-lookup jndi-name="jms/MyIncomingConnFactory"
id="myIncomingConnFactory" resource-ref="true" />  
	<jee:jndi-lookup jndi-name="jms/MyOutgoingQueue" id="myOutgoingQueue"
resource-ref="true" />
	<jee:jndi-lookup jndi-name="jms/MyIncomingQueue" id="myIncomingQueue"
resource-ref="true" />
*

	<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager"/>
		
	<bean id="messageListener"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
		*<property name="connectionFactory" ref="myIncomingConnFactory" />*
		*<property name="destination" ref="myIncomingQueue" />*
		<property name="sessionTransacted" value="true" />
		<property name="concurrentConsumers" value="1" />
		<property name="maxConcurrentConsumers" value="6" />
		<property name="messageListener" ref="myMessageProcessor" />
		<property name="transactionManager" ref="transactionManager" />
		<property name="taskExecutor" ref="msgListenersTaskExecutor" />
	</bean>

	<bean id="myMessageProcessor" class="com.test.MyMessageReceiver">
		<property name="forwardConnectionFactory" ref="myOutgoingConnFactory" />
		<property name="forwardQueue" ref="myOutgoingQueue" />
	</bean>
	
	<bean id="msgListenersTaskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"/>
</beans>
-------------------------------

What do I do wrong? :(



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676716.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Tomee, MySql, ActiveMQ, XA Distributed Transactions

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi


2015-11-02 7:08 GMT-08:00 iannuz <ia...@gmail.com>:

> Hi,
>
> I am posting this message to pre-check the feasibility of what follows
> before wasting time configuring/testing it.
>
> I'd like to know if with this platform:
> - Tomee+ 1.7.2
> - ActiveMQ 5.12.1
>

We dont bundle this one but you can override our version to this one
without issues.


> - MySql 5.7
>
> something like this is possible or not:
> <http://tomee-openejb.979440.n4.nabble.com/file/n4676680/XATransaction.png
> >
>
> In words, the flow is:
> - A message reader (i.e. a MessageDriven bean) *reads from a queue* (1) and
> processes one message triggering:
>    - *one or more inserts/updates on a database* (2)
>    - a *put of a message to another queue* (3)
>
> (1)(2)(3) operations are all part of the same XA transaction controlled by
> Tomee, so under any circumstances they either all fail or all succeed.
>
> After a bit of searching I see that both MySql and ActiveMQ provide XA
> drivers and that tomee seems to be able to create transacted resources (via
> configuration in tomee.xml) made available, together with the
> transactionManager, to the JEE application via JNDI.
> So, on paper, it sounds feasible.. I'd just like someone with experience on
> this kind of things to confirm.
>
>
Doable, only pitfall/hard part with 1.7.2 is the XA config which needs some
tuning depending your structure and goal - we have an identified issue
fixed on next version for one of our pool. However very feasible.


> Thanks!
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>