[jboss-dev-forums] [Design of JBoss Transaction Services] - Re: JTA/JTS thread disassociation semantics
jhalliday
do-not-reply at jboss.com
Thu Jan 22 06:49:08 EST 2009
OK, JBTM-474 seems to have helped somewhat. There is still an issue with some of the JCA tests[1] that use the following cleanup code:
if (!TxUtils.isCompleted(tm))
{
tm.rollback();
fail("Tx was still active");
}
rollback is called, which is correct - it's needed to ensure thread disassociation. Note that the test is broken even for the JTA case, since there may be a complete tx associated to the thread and the rollback call is needed to disassociate it even if it's already rolled back. But in the JTS case since it can't determine the tx rolled back, rollback throws an exception rather than silently working as the JTA version does.
The issue here is that a timedout JTS tx is removed at the point it times out so thereafter its status cannot be determined. For some use cases (where the client and server are collocated) we could cache the outcome at the point the tx is removed, allowing getStatus and rollback|commit to behave more similarly to the JTA version.
But that won't work in distributed cases, since the tx is remote which means we either need it to hang around as long as a client has a handle on it (i.e. it's a distributed gc problem) or we need to notify all the clients of the outcome when it terminates (i.e. communication overhead). Neither of these appeal.
Thus the JCA test is going to have to change anyhow to cope with the distributed case.
It seems to me that what the test is really in interested in is: did the tx timeout as expected. It could either register a sync and use that to set a status flag, or rely on !isActive() rather than !isCompleted. Either way it needs an exception handler around tm.rollback, since that call is going to throw an exception.
[1] org.jboss.test.jca.test.TxConnectionManagerUnitTestCase
methods testSynchronizationAfterCompletionTxTimeout
testGetManagedConnectionTimeoutTrackByTx
testGetManagedConnectionTimeout
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4203961#4203961
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4203961
More information about the jboss-dev-forums
mailing list