TransactionAbortedException 当 masstransit 收到消息时
TransactionAbortedException when masstransit receives message
这几天我都对 TransactionScope 有疑问。报错信息如下:
MassTransit.Context.ServiceBusReceiveContext Consumer Exception Exposed System.Transactions.TransactionAbortedException: The transaction has aborted.
at System.Transactions.TransactionStatePromotedAborted.CreateAbortingClone(InternalTransaction tx)
at System.Transactions.DependentTransaction..ctor(IsolationLevel isoLevel, InternalTransaction internalTransaction, Boolean blocking)
at System.Transactions.Transaction.DependentClone(DependentCloneOption cloneOption)
at System.Transactions.TransactionScope.SetCurrent(Transaction newCurrent)
at System.Transactions.TransactionScope.PushScope()
at System.Transactions.TransactionScope..ctor(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, TransactionScopeAsyncFlowOption asyncFlowOption)
at MassTransit.Transports.Msmq.TransactionalInboundMsmqTransport.ReceiveMessage(MessageEnumerator enumerator, TimeSpan timeout, Action`1 receiveAction) in d:\BuildAgent-03\work\aa063b4295dfc097\src\Transports\MassTransit.Transports.Msmq\TransactionalInboundMsmqTransport.cs:line 48
at MassTransit.Transports.Msmq.InboundMsmqTransport.<>c__DisplayClass2.<EnumerateQueue>b__0(MessageQueueConnection connection) in d:\BuildAgent-03\work\aa063b4295dfc097\src\Transports\MassTransit.Transports.Msmq\InboundMsmqTransport.cs:line 96
at MassTransit.Transports.DefaultConnectionPolicy.Execute(Action callback) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\DefaultConnectionPolicy.cs:line 42
at MassTransit.Transports.ConnectionPolicyChainImpl.Next(Action callback) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\ConnectionPolicyChainImpl.cs:line 50
at MassTransit.Transports.ConnectionHandlerImpl`1.Use(Action`1 callback) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\ConnectionHandlerImpl.cs:line 93
at MassTransit.Transports.Msmq.InboundMsmqTransport.EnumerateQueue(Func`2 receiver, TimeSpan timeout) in d:\BuildAgent-03\work\aa063b4295dfc097\src\Transports\MassTransit.Transports.Msmq\InboundMsmqTransport.cs:line 119
at MassTransit.Transports.Msmq.InboundMsmqTransport.Receive(Func`2 callback, TimeSpan timeout) in d:\BuildAgent-03\work\aa063b4295dfc097\src\Transports\MassTransit.Transports.Msmq\InboundMsmqTransport.cs:line 45
at MassTransit.Transports.Transport.Receive(Func`2 callback, TimeSpan timeout) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\Transport.cs:line 59
at MassTransit.Transports.Endpoint.Receive(Func`2 receiver, TimeSpan timeout) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\Endpoint.cs:line 351
at MassTransit.Context.ServiceBusReceiveContext.ReceiveFromEndpoint() in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Context\ServiceBusReceiveContext.cs:line 91
队列清晰,意味着下次交易成功(我认为)。
没有与此相关的堆栈跟踪。也许线程池可能与此有关?
这个错误突然开始出现,有几天了。负责处理交易的代码没有变化。
我需要帮助。有人吗?
更新 1:
此异常在生产服务器上抛出,但我无法在登台服务器或开发机器上重现它。
更新二:
所有交易都是本地的。
这听起来像是 Microsoft DTC(分布式事务协调器)的问题,在这种情况下,您可能在阅读邮件时使用了与 SQL 服务器的连接,但无法征用该连接进入分布式事务。
有许多与 MS DTC 相关的故障排除指南,因此您可能会研究检查 DTC 操作、安全性和连接性。帐户可能已过期、防火墙规则已更改或其中一个节点上的服务未启动。
问题出在有问题的 StructureMap 中。升级后一切正常。
这几天我都对 TransactionScope 有疑问。报错信息如下:
MassTransit.Context.ServiceBusReceiveContext Consumer Exception Exposed System.Transactions.TransactionAbortedException: The transaction has aborted.
at System.Transactions.TransactionStatePromotedAborted.CreateAbortingClone(InternalTransaction tx)
at System.Transactions.DependentTransaction..ctor(IsolationLevel isoLevel, InternalTransaction internalTransaction, Boolean blocking)
at System.Transactions.Transaction.DependentClone(DependentCloneOption cloneOption)
at System.Transactions.TransactionScope.SetCurrent(Transaction newCurrent)
at System.Transactions.TransactionScope.PushScope()
at System.Transactions.TransactionScope..ctor(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, TransactionScopeAsyncFlowOption asyncFlowOption)
at MassTransit.Transports.Msmq.TransactionalInboundMsmqTransport.ReceiveMessage(MessageEnumerator enumerator, TimeSpan timeout, Action`1 receiveAction) in d:\BuildAgent-03\work\aa063b4295dfc097\src\Transports\MassTransit.Transports.Msmq\TransactionalInboundMsmqTransport.cs:line 48
at MassTransit.Transports.Msmq.InboundMsmqTransport.<>c__DisplayClass2.<EnumerateQueue>b__0(MessageQueueConnection connection) in d:\BuildAgent-03\work\aa063b4295dfc097\src\Transports\MassTransit.Transports.Msmq\InboundMsmqTransport.cs:line 96
at MassTransit.Transports.DefaultConnectionPolicy.Execute(Action callback) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\DefaultConnectionPolicy.cs:line 42
at MassTransit.Transports.ConnectionPolicyChainImpl.Next(Action callback) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\ConnectionPolicyChainImpl.cs:line 50
at MassTransit.Transports.ConnectionHandlerImpl`1.Use(Action`1 callback) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\ConnectionHandlerImpl.cs:line 93
at MassTransit.Transports.Msmq.InboundMsmqTransport.EnumerateQueue(Func`2 receiver, TimeSpan timeout) in d:\BuildAgent-03\work\aa063b4295dfc097\src\Transports\MassTransit.Transports.Msmq\InboundMsmqTransport.cs:line 119
at MassTransit.Transports.Msmq.InboundMsmqTransport.Receive(Func`2 callback, TimeSpan timeout) in d:\BuildAgent-03\work\aa063b4295dfc097\src\Transports\MassTransit.Transports.Msmq\InboundMsmqTransport.cs:line 45
at MassTransit.Transports.Transport.Receive(Func`2 callback, TimeSpan timeout) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\Transport.cs:line 59
at MassTransit.Transports.Endpoint.Receive(Func`2 receiver, TimeSpan timeout) in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Transports\Endpoint.cs:line 351
at MassTransit.Context.ServiceBusReceiveContext.ReceiveFromEndpoint() in d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Context\ServiceBusReceiveContext.cs:line 91
队列清晰,意味着下次交易成功(我认为)。 没有与此相关的堆栈跟踪。也许线程池可能与此有关?
这个错误突然开始出现,有几天了。负责处理交易的代码没有变化。
我需要帮助。有人吗?
更新 1:
此异常在生产服务器上抛出,但我无法在登台服务器或开发机器上重现它。
更新二:
所有交易都是本地的。
这听起来像是 Microsoft DTC(分布式事务协调器)的问题,在这种情况下,您可能在阅读邮件时使用了与 SQL 服务器的连接,但无法征用该连接进入分布式事务。
有许多与 MS DTC 相关的故障排除指南,因此您可能会研究检查 DTC 操作、安全性和连接性。帐户可能已过期、防火墙规则已更改或其中一个节点上的服务未启动。
问题出在有问题的 StructureMap 中。升级后一切正常。