-
June 11th, 2009, 08:01 AM
#1
WCF, TransactionScope and Oracle ODP.NET
hello
I have been trying to use TransactionScope with Oracle - and ran into problem: app just crashed with un-managed exception from within oracle provider/ODP.NET
http://social.msdn.microsoft.com/For...?prof=required
I am wondering, if I were to use WCF transaction, do I *HAVE* to use Transaction scope?
For example:
Code:
[ServiceBehavior(TransactionAutoCompleteOnSessionClose=true,
TransactionIsolationLevel=IsolationLevel.ReadCommitted,
TransactionTimeout="00:00:30")]
public class ServiceClass : IServiceClass
{
[OperationBehavior(TransactionAutoComplete=true, TransactionScopeRequired=true)]
bool ISomeBankService.TransferMoney
{
TransactionOptions oTxOption = new TransactionOptions();
oTxOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
oTxOption.Timeout = TimeSpan.FromMilliseconds(AppContext.DefaultDBMaxTimeoutMillisec);
using (oScope = new TransactionScope(TransactionScopeOption.Required, oTxOption))
{
Bank1DAO.Withdraw(1000);
Bank2DAO.Deposit(1000);
}
}
}
Can I just rewrite as such:
Code:
[ServiceBehavior(TransactionAutoCompleteOnSessionClose=true,
TransactionIsolationLevel=IsolationLevel.ReadCommitted,
TransactionTimeout="00:00:30")]
public class ServiceClass : IServiceClass
{
[OperationBehavior(TransactionAutoComplete=true, TransactionScopeRequired=true)]
bool ISomeBankService.TransferMoney
{
IDbConnection oConn = DBUtil.GetConnection(...);
IDbTranaction oTx = null;
try
{
oTx = oConn.BeginTransaction();
Bank1DAO.Withdraw(1000);
Bank2DAO.Deposit(1000);
oTx.Commit();
} catch(Exception ex)
{
oTx.Rollback();
...
}
}
}
Will it work?
(This is actually not best example - usually only transaction that span user-think-time gets across WCF boundary - certainly not withdraw-deposit scenario)
Last edited by THY02K; June 11th, 2009 at 08:15 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|