-
15. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jf321023 Mar 12, 2012 11:06 AM (in response to sfcoy)Thank you Stephen . I tried close the AutoCommit . It's successful
-
16. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jbertram Mar 12, 2012 11:09 AM (in response to jf321023)If you were looking up the datasources properly from JNDI instead of creating them manually (as you are doing in your example) auto-commit would be set appropriately for you automatically.
-
17. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jf321023 Mar 12, 2012 11:27 AM (in response to jbertram)We main goal is supporting for multiple datasource , so the xa transaction is must need. Whether using JNDI is nothing serious. Think you for reply.
I will have a try using JPA in JBoss As 7.1.1.Final . There is a bug about transaction in Jbossas7.1.0.Final, I think this is why i failed in seam3 and jpa
-
18. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jbertram Mar 12, 2012 11:55 AM (in response to jf321023)Whether or not you need to use XA is not in doubt. As you said, you must use XA to get an atomic commit between the 2 resources.
I can't speak to the Seam or JPA issues, but then again that isn't my point. My point is that your example was creating the datasource objects manually instead of looking them up in JNDI. These two are not equivalent. If you create the datasource object yourself you will not receive the benefit of using the JDBC JCA RA which takes care of enlisting the XA resource into the running transaction (among other things).
-
19. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jf321023 Mar 12, 2012 12:00 PM (in response to jbertram)I changed my first test, i set the SqlConnect autocommit to false. the xa transaction is fine. so i think this is the main reason.
-
20. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jf321023 Mar 12, 2012 12:06 PM (in response to jbertram)I am sorry , you are right
-
21. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jf321023 Mar 12, 2012 12:16 PM (in response to jbertram)Using jndi , i just get the DataSource but not XaDataSource , so i can't begin the database's local transaction, then the JTA also can't manager the transaction
-
22. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jbertram Mar 12, 2012 12:21 PM (in response to jf321023)You can certainly do all this stuff manually (i.e. embed the connection URLs, usernames, and passwords in your code, call setAutoCommit, etc.). Whether or not you can do it manually is not in doubt. However, whether or not you should do it manually seems clear to me - you shouldn't. Doing this manually gives up significant advantages. Your code would be much simpler, your performance will likely be much better, and your management would be easier if you use a JCA JDBC datasource. -
23. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jbertram Mar 12, 2012 12:24 PM (in response to jf321023)As I've already said on this thread, you don't need a handle in your code to an XaDataSource object. The JCA JDBC RA will take care of all the XA underpinnings for you. Just look-up the datasource in JNDI, use container-managed transactions, and run your SQL. This is the same way it's been done for years in Java EE.
-
24. Re: JTA UserTransaction for Multiple DS have a issue when rollback
jf321023 Mar 12, 2012 12:38 PM (in response to jbertram)Thank you very very much I tried successfully.