-
1. Re: when to use xa-datasource
onaed Jun 25, 2010 1:25 AM (in response to testrot)Hi Martin,
I've just been reading JBoss in Action as well and was also stumped by what they said.
Like yourself I thought XA was only required for multiple data sources (or other branches in the transaction e.g JMS).
Fellow colleagues of mine insist this is what it means.
So I can't confirm 100%, but I'm sure (and so are my colleagues) the book is wrong
Regards
Dean
-
2. Re: when to use xa-datasource
testrot Jun 25, 2010 2:25 AM (in response to onaed)Hi Dean,
thanks for your answer. I already thought I am the only fool not understanding this book passage.
I will try to confirm our opinion and ask the authors of JBoss in Action.
If I get any answer I will post it here.
Regards,
Martin
-
3. Re: when to use xa-datasource
peterj Jun 25, 2010 11:11 AM (in response to testrot)1 of 1 people found this helpfulAt the time that I wrote this text I checked this with the JBoss engineers and that is what they stated - the XA data source is required only when multiple JBoss AS instances are involved, or when you have JBoss AS and some external service all managed by a transaction manager. Two-phase commit within a single JBoss AS instance is handled by the local data source.
-
4. Re: when to use xa-datasource
testrot Jun 28, 2010 6:04 AM (in response to peterj)Hello Peter,
thanks for your reply and btw for writing this book. It's really very usefull for my daily work.
Regarding my question I am still not totally convinced. I don't want to be annoying, but perhaps you mixed two aspects of transactions in JBoss when writing the book or discussing with the jboss engineers. I did a lot of research to get the whole picture and right now I guess the following:
local-tx-datasource vs. xa-datasource
There are local-tx-datasources and xa-datasources. local-tx-datasources can be used if there aren't any transactions spanning multiple transactional resources. As soon as you use two or more transactional resources in the same transaction e.g. a transactional session bean method manipulating JPA entities and producing JMS messages, you must use xa-datasources for the transactional resources.
JBossTS JTA for local-only transactions vs. JBossTS JTS for distributed transactions
If you use xa-datasources you need a transaction manager to coordinate the resources (with 2PC). This http://community.jboss.org/wiki/JBossTransactionsVersionGuide wiki page and this http://www.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/5.0.1/html/Administration_And_Configuration_Guide/transaction.html#id2524403 guide state, that there are two different implementations or modules for this transaction manager. The JBossTS JTA module for local-only transactions and the JBossTS JTS module for distributed transactions. Both are capable to handle multiple XA resources but JBoss JTS can handle distributed transactions spanning multiple VMs and JBossTS JTA can only handle transactions in a single VM. In case of jboss clusters I'm not sure if every cluster configuration needs JBoss JTS. I would guess that in a homogenous cluster JBoss JTA is sufficient because a transaction startet by a transaction manager on a certain cluster node does not leave this node and thus stays in a single VM.
As I said this is only my current guess about I think transactions within JBoss AS are working. Can anybody confirm or deny this?
Regards,
Martin
-
5. Re: when to use xa-datasource
jhalliday Jun 28, 2010 8:20 AM (in response to testrot)Martin is correct. The book unfortunately is not. Hope the JBoss engineer in question wasn't me on a bad day :-)
Jonathan Halliday
JBoss Transactions dev team lead.
-
6. Re: when to use xa-datasource
testrot Jun 28, 2010 8:40 AM (in response to jhalliday)Hello Jonathan,
thanks for clarifying things. I whish I would get such statements ("Martin is correct") more often :-).
Can you also confirm my guess about homogenous clusters? Is JBoss JTA sufficient for homogenous clusters or do I need JBoss JTS?
Thanks to all of you who answered my post!
-
7. Re: when to use xa-datasource
peterj Jun 28, 2010 12:21 PM (in response to testrot)I think that some of the discussion took place in the JBoss Transactions forum, but that was 3 or 4 years ago (wow, was it really that log ago when I started working on the book..) but I can't find the thread. Though there were some teleconferences - my team at the time was contemplating some possible work with the transaction service, I'm pretty sure that Mark Little was involved (or maybe I just remember that from an even earlier meeting with Arjuna), not sure who else was involved. Of course, it is very possible that I misinterpreted what was said.
But it looks like an errata update is warranted - Martin, I hope you don't mind if I plagiarize your text.
-
8. Re: when to use xa-datasource
testrot Jun 29, 2010 3:17 AM (in response to peterj)No problem.
Regards,
Martin
-
9. Re: when to use xa-datasource
onaed Jun 29, 2010 6:30 PM (in response to testrot)Thanks guys. Your input has been much appreciated.
I'd just also like to add, thank's to Peter for writing JBoss in Action.
-
10. Re: when to use xa-datasource
henk53 Oct 17, 2010 12:24 PM (in response to testrot)There are some additional things to mention here.
JBoss AS does seem to do the so-called "Last-Resource Gambit" (term coined by Mike Spille, see http://www.jroller.com/pyrasun/category/XA), aka Last Resource Commit Optimization (see http://community.jboss.org/wiki/Multiple1PC).
This means that when dealing with multi datasources within a single JTA transaction, one of them is allowed to be a non-XA datasource. I explicitly tested this on JBoss AS 5.1 with one XA JDBC datasource and one local TX JDBC datasource, as well as with one XA JMS connection factory (the standard java:/JmsXA one) and local TX JDBC datasource.
In both these situations, JBoss AS happily processed the transaction without complaining.
As soon as you use 2 local TX JDBC datasources however, an exception like the following is thrown when a connection from the second data source is attempted to be obtained:
17:58:01,069 WARN [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] Adding multiple last resources is disallowed. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@5fd8aca1 17:58:01,070 INFO [STDOUT] Interceptor.invoke(StatelessInstanceInterceptor.java:68) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79) [...] org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: a0000bd:c381:4cbb1bf2:ae status: ActionStatus.ABORT_ONLY >) at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
-
11. Re: when to use xa-datasource
henk53 Oct 17, 2010 1:18 PM (in response to testrot)One thing I wonder though, how efficient is the one-phase optimization in JBoss AS, especially in combination with the local-tx-datasource.
Suppose you have an application where 95% of time only a single JDBC datasource participates in a transaction and in 5% of the cases multiple resources participate.
Would it then be more efficient to use a local-tx-datasource for the resource that is used 95% of the time and rely on Last Resource Commit Optimization, or would JBoss AS be smart enough to do an efficient one-phase optimization in those cases where there is only one participant in the transaction?
If the latter is true, why is there even an local-tx-datasource and not just only an xa and no-tx datasource?
-
12. Re: when to use xa-datasource
testrot Oct 18, 2010 3:25 AM (in response to henk53)Hello Henk,
Would it then be more efficient to use a local-tx-datasource for the resource that is used 95% of the time and rely on Last Resource Commit Optimization, or would JBoss AS be smart enough to do an efficient one-phase optimization in those cases where there is only one participant in the transaction?
I did some tests and I am pretty sure, that JBoss uses one-phase commit optimization for transactions with only one participant. Except it is disabled by configuration.
-
13. Re: when to use xa-datasource
hifly81 Oct 18, 2010 3:44 AM (in response to testrot)good that you've found this mistake in the book testrot! it's not a minor issue!
-
14. Re: when to use xa-datasource
atijms Oct 18, 2010 5:25 AM (in response to testrot)testrot wrote:
I did some tests and I am pretty sure, that JBoss uses one-phase commit optimization for transactions with only one participant. Except it is disabled by configuration.
What configuration would that be? I tried to do some searching for "one-phase" and "1pc" in the JBoss documentation, but nothing really came up.