View Full Version : Is TxScopeTransactionManager is complete or still under development
I am using TxScopeTransactionManager and framework is throwing "The DoResume mehtod is not implemented." exception.
After looking at code base I noticed DoSuspend, DoResume and DoSetRollbackOnly methods don't have any implementation.
Mark Pollack
01-25-2007, 07:16 PM
Hi,
Those methods should be removed and the "no-op" implementations used from the abstract base class as I'm pretty sure this functionality is not supported by MTS, but I'll double check.
In the meantime, a likely reason you are going down that code pathway is because you are using the TransactionPropagation setting of "RequiresNew". Use "Requires" instead. Otherwise you can remove those methods yourself and recompile.
If that doesn't help, take a look at the quickstart "TxQuickStart". It shows use of TxScopeTransactionManager. See the class AccountManagerTests.cs and the config file DTCAppContext.xml for details. That may also help resolve your issue.
Thanks for reporting this, I've made a JIRA entry to remind me to remove it.
Mark
Hi Mark,
I have Command object which is configured to use TransactionInterceptor using TxScopeTransactionManager, NameMatchTransactionAttributeSource
and Execute* method set for PROPAGATION_REQUIRED. Command object interacts with Dao which uses AdoTemplate.
And then I have Facade which is configured to use TransactionProxyFactoryObject using TxScopeTransactionManager, NameMatchTransactionAttributeSource
and Save* method set for PROPAGATION_REQUIRED. Facade interacts with Dao which uses HibernateTemplate.
During execution of command object it's calling Facade. So now my command object uses both AdoTemplate and HibernateTemplate through facade.
When I use HibernateTransactionManager instead of TxScopeTransactionManager it's working fine. But when I use TxScopeTransactionManager it throws exception
"Transaction manager [TxScopeTransactionManager] does not support transaction suspension".
Does this mean TxScopeTransactionManager is not design works with AdoTemplate and HibernateTemplate under single transaction?
Mark Pollack
01-26-2007, 09:10 PM
Hi,
If you are using a single database then use AdoTemplate and HiberateTemplate with HibernateTransactionManager. Both ado.net/nhibernate operations will participate in the same local transaction. If you need distributed transactions that is when you should use TxScopeTransactionManager. In either case the design goal is to be able to mix ado/nhiberate operations but it looks like there is a bug when using TxScopeTransactionManager.
I'm surprised that with PROPAGATION_REQUIRED DoSuspend is being called. I will investigate. Can you remove the transaction delcaration on the Facade and call the command object methods as a quick test? My guess that is that the bug lies in that nesting. Sorry for making you remove the "NotImpl" exception in TxScopeTransactionManager only to get a different exception thrown from the base class - my bad.
Cheers,
Mark
Hi Mark,
After removing transaction declaration from Facade it works. So looks like there is problem in nesting.
Thanks
Ajay
Mark Pollack
01-26-2007, 09:31 PM
Hi Ajay,
Good to hear. But do you *need* TxScopeTransactionManager in anycase?
Mark
Hi Mark,
First reason good to have is
We are using both SQL and Oracle databases in our application.
And second reason
Some transactions are initiating from Old code using TransactionScope.
Thanks,
Ajay
Hi Mark,
After debugging through TxScopeTransactionManager, I noticed 'IsExistingTransaction' method always return false because txObject.TransactionScope is null all the time.
In my code, Command object starts transaction save some data and during further processing it calls save method on Facade object. When facade save method is called IsExistingTransaction returns false even though there is already transaction started by Command.
So I made following change to IsExistingTransaction method
protected override bool IsExistingTransaction(object transaction)
{
PromotableTxScopeTransactionObject txObject =
(PromotableTxScopeTransactionObject)transaction;
//if (txObject.TransactionScope != null
// && System.Transactions.Transaction.Current != null)
if (System.Transactions.Transaction.Current != null)
{
return true;
}
else
{
return false;
}
}
After this change my command and Facade objects are working fine. Also I have some scenarios where my code is starting TransactionScope and inside it calls spring transaction based Facade objects. This code is also working fine after this change.
What do you think about this change? or Am I missing something?
Regards,
Ajay
Mark Pollack
03-08-2007, 03:03 PM
Hi Ajay,
This is a bug. I've made a JIRA issue to investigate further, txObject.TransactionScope, should not be null. A high priority item for me is extensive unit tests around the spring.data namespace to weed out these remaining issues. As such, conservatively speaking, you can say all of Spring.Data is still under development, but in practice many clients have been using it without issue even in production environments. The goal is to have 1.0 final out by the summer (June-ish). Thanks very much for taking the time to dig through the issue and report it.
Cheers,
Mark
Mark Pollack
07-04-2007, 01:21 AM
Hi Ajay,
I fixed this bug which occurs if there are nested transaction scopes. I moved the check into the helper class PromotableTxScopeTransactionObject to be consistent with the style of other implementations. Thanks again for finding out the root cause.
Mark
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.