2012-01-30 96 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”,因为数据库引发的异常需要被捕获和处理,而不是折叠分布式事务。现在它的行为如预期。

感谢您的意见,我会重新审视代码并在机上提出您的意见。