-
1. Re: How more than one XA Datasources participate in one container managed transaction ?
wdfink Dec 12, 2012 8:36 AM (in response to jboss.new.user)You should clarify what you mean by distributed transaction.
If the transaction use different JCA connections inside the server the only thing is to have all such resources handle XA (two phase commits) correct.
Also a client can initiate the Tx if it is using the same server (you need transaction stickyness in this case).
If you mean that the Tx span different server instances, i.e. two EJB's on different servers you need to have a JTS configuration instead of the (default) JTA. There are scripts in the docs directory to change the configuration.
-
2. Re: How more than one XA Datasources participate in one container managed transaction ?
jboss.new.user Dec 12, 2012 10:57 AM (in response to wdfink)Hi Fink,
Thanks for replying.
Let's take this to elaborate a little.
JBoss AS is configured for JTS. One XA datasource is on dataSourceServer A and another XA datasource is on dataSourceServer B. All my EJBs are there on the same JBoss server (same node, single instance). Just for the sake of simplicity something is needed to be done on datasource A and datasource B where actionA and actionB corresponds to datasource A and datasource B respectively. Here actionA & actionB should be done as a part of one single transaction.
Now in case of BMT we can get the datasource via JNDI lookup and do the operation and complete the transaction by using TransactionManager of the JBoss or even by using XAResource and its lifecycle methods for two-phase commit.
But in case of CMT how we are going to achieve this. This is the point of confusion for me. How in case of CMT transactionManager will call the methods of two-phase commit ? How it will understand that which XA--Datasources are involved (is there any way to configure this ?) ?
-
3. Re: How more than one XA Datasources participate in one container managed transaction ?
wdfink Dec 13, 2012 11:03 AM (in response to jboss.new.user)1 of 1 people found this helpfulIf you use CMT the container will track which resource is involved in the transaction.
If the EJB is finished (mean that the business method return) the container will send a prepare to all XA resources and if successful a commit.
It is the responsibility of the container how to do this. AFAIK JBoss will send prepare/commit in that order the resources are got from the container( but this might change with different versions).
Also if you use different resources from an EJB, or a couple of EJB's, inside the same JBoss instance you do not need a JTS configuration. It will be more complex and might have performance drawbacks as it uses IIOP.
So a Tx is committed if you return from a method with a different Tx scope, let me shown an example:
Method1 (Tx.Required)
do DB stuff
-> M2 (Tx.NotSupported)
Tx1 suspended
-> M3 (Tx.Required)
Tx2
do DB stuff maybe different DB'S
return
<- (prepare)commit Tx2
<-
<-
(prepare)commit Tx1
The commits are done by the container outside your code (also outside the interceptors)
There is no configuration to control that.
-
4. Re: How more than one XA Datasources participate in one container managed transaction ?
jboss.new.user Dec 14, 2012 2:17 AM (in response to wdfink)Thanks Fink. Your reply helps.