2010-02-22 112 views
1

我正面臨下一個問題。我有一段代碼是這樣的:消息隊列中的TransactionScope問題

DoSomething(){ 
    using (TransactionScope scope = new TransactionScope()) 
    { 
     InsertSomething(); 
     InsertSomethingElse(); 
     InsertYetAnotherThing(); 
     ProcessDataRelatedWithThePreviousInserts(); 
     scope.Complete() 
    } 
} 

在ProcessDataRelatedWithThePreviousInserts我檢查條件,如果需要,工作流程的其餘部分被重定向到消息隊列中的其它服務器。在其他服務器中,我恢復該消息,並繼續工作流程(基本上,進行一些與DoSomething方法中的相關的其他插入操作)。

這是理論上的,因爲我只是設法做到這一點,如果我刪除了DoSomething方法中的TransactionScope。有沒有辦法完成我想要做的事情,或者我需要改變交易的處理方式?

+0

您是否按照我的建議嘗試過?任何成功? – Filburt 2010-03-04 18:39:42

回答

0

您是否已經嘗試

using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) 
{ 
    // ... 
    using (TransactionScope innerscope = new TransactionScope(TransactionScopeOption.Supress) 
    { 
     ProcessDataRelatedWithThePreviousInserts(); 
    } 
    scope.Complete(); 
} 

明確supressing外交易,您的來電ProcessDataRelatedWithThePreviousInserts()