2

我在 Windows Server 2008 上使用 C#,我想从同一域中另一台计算机上的公共事务队列接收消息。错误如下所示:

System.Messaging.MessageQueueException: Cannot import the transaction.
   at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)
   at System.Messaging.MessageQueue.Receive(TimeSpan timeout, MessageQueueTransactionType transactionType)
   at JobManagerLib.JobProcessor.Process(Action waitForNewMessageCallback) in C:\Dev\OtherProjects\POC\WindowsService\JobManagerSample\JobManagerLib\JobProcessor.cs:line 132

我试过 DTCPing,它在一个方向上成功但在另一个方向上失败了。以下是日志的相关部分:

++++++++++++hosts      ++++++++++++
127.0.0.1       localhost
::1             localhost

08-20, 15:47:22.739-->Error(0x424) at clutil.cpp @256
08-20, 15:47:22.739-->-->OpenCluster
08-20, 15:47:22.739-->-->1060(The specified service does not exist as an installed service.)
++++++++++++++++++++++++++++++++++++++++++++++
     DTCping 1.9 Report for DEV-MSMQ2  
++++++++++++++++++++++++++++++++++++++++++++++
RPC server is ready
++++++++++++Validating Remote Computer Name++++++++++++
08-20, 15:47:26.207-->Start DTC connection test
Name Resolution:
    dev-msmq1-->192.168.22.11-->Dev-msmq1
08-20, 15:47:26.222-->Start RPC test (DEV-MSMQ2-->dev-msmq1)
RPC test failed

有谁知道为什么这可能会失败?已为 MSDTC 打开 Windows 防火墙。很难找到有关 Windows 2008 和 MSMQ 的大量信息。

编辑:队列名称为 FormatName:DIRECT=OS:dev-msmq1\getmap 和 FormatName:DIRECT=OS:dev-msmq1\logevent。它们是公共的、事务性的队列,每个人都拥有查看/接收它们的权限。我的代码的相关部分如下:

using (TransactionScope tx = new TransactionScope(TransactionScopeOption.RequiresNew))
{
    using (var queue = new MessageQueue(QueueName))
    {
        queue.Formatter = new XmlMessageFormatter(new string[] { _targetParameterType });
        var message = queue.Receive(TimeOut, MessageQueueTransactionType.Automatic);
        string messageId = message.Label;

...
    }
}

谢谢

4

3 回答 3

1

所以我确实找到了一个解决方案:完全放弃整个事情,转而使用 WCF 和 net.Msmq 绑定。现在队列通信工作正常。

于 2009-10-09T16:50:17.403 回答
0

确保两台机器的时钟同步。我之前看到过身份验证将失败,因为服务器和客户端的关闭时间相差一分钟。即使队列是公开的并且对每个人都具有权限,这种情况也会发生。

于 2009-09-02T17:47:58.833 回答
0

仅出于完整性考虑,在运行 IPv4 时仅允许 MSDTC 和 MSMQ 通过防火墙是不够的:

您还需要让 ICMP 流量通过防火墙(无论防火墙如何,IPv6 都可以解析主机名,但您的 DTCPing 日志表明您正在运行 IPv4)。

我一直在努力解决您在 DTCPing 中看到的相同错误,在我的情况下,它原来是由阻止 ICMP 流量的防火墙触发的。

于 2009-11-22T16:36:45.803 回答