我在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;
...
}
}
感謝
也許發佈您的代碼或您的隊列配置。對於隊列名稱的格式,MSMQ可能會很挑剔。 – Web 2009-08-20 20:08:34
但實際名稱是什麼? (http://technet.microsoft.com/en-us/library/cc778392(WS.10).aspx)。雖然我認爲這涉及到交易。 (MSDTC)。從來沒有使用過,但。抱歉。 – 2009-08-21 02:39:39
對不起......此處使用的隊列名稱是FormatName:DIRECT = OS:dev-msmq1 \ SendEmail和FormatName:DIRECT = OS:dev-msmq1 \ LogEvent。 – 2009-08-21 17:06:09