2012-01-30 97 views
1

流程訂單:佐賀完成原因分佈式事務處理已完成的錯誤

  • 佐賀消息處理程序接收包含數據項的第一消息。
  • 消息處理程序使用具有自己的數據庫事務的業務對象。
  • 如果項目更新OK,數據庫事務提交和傳奇完成。
  • 佐賀消息處理程序接收包含數據項的第二條消息。
  • 消息處理程序拋出異常,試圖按照上面的方式打開新的數據庫事務。

錯誤消息:

System.Data.SqlClient.SqlException (0x80131904): Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction. 

堆棧跟蹤:

2012-01-27 14:07:47,407 [Worker.9] ERROR 

LawCover.LISServices.LISBankAgent.SagaMessageHandler [(null)] - Exception details 
System.Data.SqlClient.SqlException (0x80131904): Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction. 
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) 
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) 
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() 
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 
    at System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest) 
    at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest) 
    at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest) 
    at System.Data.SqlClient.SqlInternalConnection.BeginSqlTransaction(IsolationLevel iso, String transactionName) 
    at System.Data.SqlClient.SqlConnection.BeginTransaction(IsolationLevel iso, String transactionName) 
    at System.Data.SqlClient.SqlConnection.BeginTransaction() 
    at LawCover.LIS.DataAccess.ConnectionManager.BeginTransaction() 
    at LawCover.LISServices.LISBankAgent.LISMethods.AddCreditCardPaymentSettlementScheduleItemsAndReceiptsIntoLISForCurrentMessages(BankResponseFileProcessed message) in C:\Projects\LIS Improvements\LIS\Source\LISServices\LISBankAgent\LISMethods.cs:line 53 
    at LawCover.LISServices.LISBankAgent.SagaMessageHandler.Handle(BankResponseFileProcessed message) in C:\Projects\LIS Improvements\LIS\Source\LISServices\LISBankAgent\SagaMessageHandler.cs:line 177 

有相當多的覆蓋上述流程的代碼,但我很高興地張貼的內容將是有益的。

+1

請參閱我對您的其他帖子的評論:http://stackoverflow.com/questions/9028331/why-does-nservicebus-saga-timeout-request-use-wrong-saga-id – 2012-02-01 13:41:21

回答

3

我剝離了事務以發現事件處理程序正在打開另一個數據庫連接,並且默認情況下,該連接已被註冊到DTC中。我在連接字符串中添加了「Enlist = false」,因爲數據庫引發的異常需要被捕獲和處理,而不是摺疊分佈式事務。現在它的行爲如預期。

感謝您的意見,我會重新審視代碼並在機上提出您的意見。