MSDTC 事务管理器无法使用 AmbientTransaction 推送事务

The MSDTC transaction manager was unable to push the transaction using AmbientTransaction

我有一个 BizTalk 解决方案,它会调用一个存储过程来查询和更新 table。显然我每次在负载平衡服务器中测试我的解决方案时都会遇到此错误。

The adapter failed to transmit message going to send port SQLAdapter_Sendport" with URL "mssql://server//StoredProc?". It will be retransmitted after the retry interval specified for this Send Port.

Details: System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed.

System.Runtime.InteropServices.COMException: The MSDTC transaction manager was unable to push the transaction to the destination transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn't have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers.

Exception from HRESULT: 0x8004D02A)
at System.Transactions.Oletx.ITransactionShim.Export(UInt32 whereaboutsSize, Byte[] whereabouts, Int32& cookieIndex, UInt32& cookieSize, CoTaskMemHandle& cookieBuffer)
at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)
--- End of inner exception stack trace ---

我已经阅读了一些文章,我应该如下设置 DTC 属性。我已经在 BizTalk 和 SQL 服务器中设置了这些。

还必须在 Windows 防火墙中添加 DTC。

最后,如果发送端口属性中的 useAmbientTransaction 设置为 True,我会不断遇到上述错误。

但是如果我将 useAmbientTransaction 设置为 False,则消息在 SQL 中成功。

我在一些文章中读到,Microsoft 不建议将 useAmbientTransaction 设置为 False,尤其是在存储过程中涉及 Update 和 Delete 的情况下。但是我的解决方案在存储过程中使用删除和更新,这就是为什么我需要将它的 useAmbientTransaction 设置为 True。但是如果我这样做,我会不断遇到错误 "MSDTC transaction manager was unable to push the transaction to the destination..."

请为此提出任何可能的解决方案。

如果您要连接到 AlwaysOn 可用性组中的数据库,则需要关闭 useAmbientTransaction,因为 AlwaysOn 不支持 MSDTC,SQL Server 2016 除外。

SQL Server 2014 的同一篇文章Cross-Database Transactions Not Supported For Database Mirroring or AlwaysOn Availability Groups (SQL Server)

SQL 服务器 2016 Cross-Database Transactions and Distributed Transactions for Always On Availability Groups and Database Mirroring (SQL Server)