【发布时间】:2018-09-06 22:36:51
【问题描述】:
很久以前,我已经设置了一个带有 MSMQ 并使用 DTC(也是集群)的集群环境,并且能够使用 C# 将消息放入队列中没有问题。
今天,除了使用 Windows Server 2012 之外,我需要设置相同的环境,并且我设法让它启动并运行。唯一的问题是,当我尝试将消息放入队列时,应用程序崩溃并显示以下内容:
未处理的异常:System.Transactions.TransactionAbortedException: 事务已中止。 ---> System.Transactions.TransactionException:MSDTC 无法读取其 配置信息。 (来自 HRESULT 的异常:0x8004D027)- --> System.Runtime.InteropServices.COMException:MSDTC 无法读取其配置信息。 (HRESULT 的例外情况: 0x8004D027) 在 System.Transactions.Oletx.IDtcProxyShimFactory.ConnectToProxy(字符串 节点N ame, Guid resourceManagerIdentifier, IntPtr managedIdentifier, Boolean& nodeName Matches, UInt32& whereaboutsSize, CoTaskMemHandle& whereaboutsBuffer, IResourceM anagerShim&resourceManagerShim) 在 System.Transactions.Oletx.DtcTransactionManager.Initialize() --- 内部异常堆栈跟踪结束 --- 在 System.Transactions.Oletx.OletxTransactionManager.ProxyException(COMExcept 离子comException) 在 System.Transactions.Oletx.DtcTransactionManager.Initialize() 在 System.Transactions.Oletx.DtcTransactionManager.get_ProxyShimFactory() 在 System.Transactions.Oletx.OletxTransactionManager.CreateTransaction(Transa 选项属性) 在 System.Transactions.TransactionStatePromoted.EnterState(InternalTransaction n TX) --- 内部异常堆栈跟踪结束 ---
该应用程序非常简单直接。多次使用它。适用于本地计算机队列,并且几年前上次使用相同的应用程序在集群中的事务性 msmq 上放置消息:
var anOrder = new Order { OrderID = 1, ShipToAddress = "123 Abc avenue", ShipToCity = "Seattle", ShipToCountry = "A country", ShipToZipCode = "12345", SubmittedOn = DateTime.UtcNow };
// create a MessageQueue to tell MSMQ where to send the message and how to connect to it
var configSettingQueue = ConfigurationManager.AppSettings["MessageQueuePath"];
var queue = new MessageQueue(configSettingQueue);
// Create a Message and set the body to the order object above
var msg = new Message { Body = anOrder };
// Create a transaction
using (var ts = new TransactionScope(TransactionScopeOption.Required))
{
queue.Send(msg, MessageQueueTransactionType.Automatic); // send the message
ts.Complete(); // complete the transaction
}
有什么想法吗? DTC 允许传入和传出交易,也不需要身份验证。
难倒!
在事件查看器中,我得到了这个:
Failed to initialize the needed name objects. Error Specifics: hr = 0x80004005, com\complus\dtc\dtc\msdtcprx\src\dtcinit.cpp:575, CmdLine: DNCDispatcher.exe, Pid: 1812
没有安装或使用 SQL。只是集群 MSMQ。
【问题讨论】:
-
更多信息:我刚刚发现如果我以域管理员(不是域中的用户!)身份登录,那么消息就会成功发送到队列。为什么?!如何?!即使 MSDTC 或 MSMQ 不需要身份验证......有什么想法吗?