2009-08-20 120 views
1

我在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 

有没有人知道为什么这可能会失败? Windows防火墙已经为MSDTC打开。很难找到关于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; 

... 
    } 
} 

感谢

+0

也许发布您的代码或您的队列配置。对于队列名称的格式,MSMQ可能会很挑剔。 – Web 2009-08-20 20:08:34

+0

但实际名称是什么? (http://technet.microsoft.com/en-us/library/cc778392(WS.10).aspx)。虽然我认为这涉及到交易。 (MSDTC)。从来没有使用过,但。抱歉。 – 2009-08-21 02:39:39

+0

对不起......此处使用的队列名称是FormatName:DIRECT = OS:dev-msmq1 \ SendEmail和FormatName:DIRECT = OS:dev-msmq1 \ LogEvent。 – 2009-08-21 17:06:09

回答

1

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

0

两台计算机必须运行MSDTC因为远程交易是在玩。

This blog article offers a tiny hint...

由于防火墙可以发挥,确保端口1801(MSMQ)是两侧敞开。

+0

提到的两台机器实际上都在运行MSDTC。任何其他想法? – 2009-09-01 19:12:49

0

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

0

只是为了保持完整性,只允许MSDTC和MSMQ通过防火墙运行IPv4的时候是不够的:

你需要让ICMP流量通过防火墙以及(IPv6的可以不管解决防火墙的主机名,但您的DTCPIng日志表明您正在运行IPv4)。

我一直在与你在DTCPing中看到的相同的错误挣扎,在我的情况下,它竟然被阻止ICMP流量的防火墙触发。