|
Hi!
I have a question (it could be an observation if already
had more self-confidence) about enlisting/delisting xa resources in the
Transaction implementation. Here are the sources of both methods as they
were in last week CVS repository (remember that resources is a
Vector):
public boolean delistResource(XAResource xaRes,
int flag)
{ try { xaRes.end(xid, Status.STATUS_ACTIVE); // resources.removeElement(xaRes); return true; } catch(XAException e) { e.printStackTrace(); return false; } } public boolean enlistResource(XAResource
xaRes)
throws RollbackException { // Check rollback only if (status == Status.STATUS_MARKED_ROLLBACK) { throw new RollbackException(); } // Add
resource
try { xaRes.start(xid, Status.STATUS_ACTIVE); resources.addElement(xaRes); return true; } catch(XAException e) { e.printStackTrace(); return false; } } When the transaction commits (or rollback) the algorithm
is:
[...]
for
(int i = 0; i < resources.size();
i++)
{
try
{ ((XAResource)resources.elementAt(i)).commit(xid, false); } catch (XAException e) { try { ((XAResource)resources.elementAt(i)).forget(xid); } catch(XAException another) {} e.printStackTrace(); // TODO: what to do here? } } So the question is:
What if we have more than one xa resource enlisted in the
transaction corresponding to the same resource manager? I think that in this
scenario the algorithm will run the 2 phase protocol against the same
resource manager and for the same transaction more than once.
Regard this, the JTA spec says:
"
The enlistResource request results in the
Transaction Manager informing the
resource manager to start associating
the transaction with the work performed through
the corresponding resource—by invoking
the XAResource.start method. The
Transaction Manager is responsible for
passing the appropriate flag in its
XAResource.start method call to the resource manager. The XAResource interface
is described in section
3.4.
If the target transaction already has
another XAResource object participating in the
transaction, the Transaction Manager
invokes the XAResource.isSameRM method to
determine if the specified XAResource represents the same
resource manager instance.
This information allows the TM to group
the resource managers who are performing
work on behalf of the
transaction.
1.Transaction Branch is defined
in the X/Open XA spec [1] as follows: 'A global transaction has one
or
more transaction branches. A
branch is a part of the work in support of a global transaction for which
the
TM and the RM engage in a
separate but coordinated transaction commitment protocol. Each of the
RM’s
internal units of work in
support of a global transaction is part of exactly one branch. .. After the TM
begins
the transaction commitment
protocol, the RM receives no additional work to do on that transaction
branch.
The RM may receive additional
work on behalf of the same transaction, from different branches. The
differ-ent
branches are related in that
they must be completed atomically. Each transaction branch identifier
(or
XID) that the TM gives the RM
identifies both a global transaction and a specific branch. The RM may
use
this information to optimise its
use of shared resources and locks.'
" That's all for now.
Thank you,
Carlos
|
- RE: [jBoss-Dev] TransactionImpl Carlos Pita
- RE: [jBoss-Dev] TransactionImpl marc fleury
- RE: [jBoss-Dev] TransactionImpl Jason Sando
- RE: [jBoss-Dev] TransactionImpl marc fleury
- RE: [jBoss-Dev] TransactionImpl Aaron Mulder
- RE: [jBoss-Dev] TransactionImpl marc fleury
- RE: [jBoss-Dev] TransactionImpl Carlos Pita
- [jBoss-Dev] rmi,transactions,orbs ... Carlos Pita
- Re: [jBoss-Dev] rmi,transactio... Rickard �berg
- RE: [jBoss-Dev] rmi,transactio... marc fleury
- Re: [jBoss-Dev] rmi,transactio... Rickard �berg
