views:

633

answers:

4

I'm using C# on Windows Server 2008, and I want to receive a message from a public transactional queue on another machine in the same domain. The error looks like this:

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

I've tried DTCPing, which succeeds in one direction but fails in the other. Here is the pertinent part of the log:

++++++++++++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

Does anybody have any idea why this might be failing? The Windows Firewall has been opened for MSDTC. It's hard to find much info about Windows 2008 and MSMQ.

EDIT: The queue names are FormatName:DIRECT=OS:dev-msmq1\getmap, and FormatName:DIRECT=OS:dev-msmq1\logevent. They are public, transactional queues, and Everyone has peek/receive permission on them. The pertinent part of my code is as follows:

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;

...
    }
}

Thanks

A: 

Both machines must be running MSDTC since a remote transaction is in play.

This blog article offers a tiny hint...

Since a firewall may be in play, make sure port 1801 (MSMQ) is open on both sides.

Joe Caffeine
Both machines mentioned are in fact running MSDTC. Any other ideas?
Dave Nichol
A: 

Make sure, both machine's clocks are in sync. I seen this before where authentication will fail because the server and the client are off time by a minute. This will happen even if the queues are public and have permissions on everyone.

A: 

So I did find a solution: abandon the whole thing altogether and switch to using WCF and the net.Msmq binding. Now the queue communication is working fine.

Dave Nichol
A: 

Just for completeness, allowing only MSDTC and MSMQ through the firewall is not enough when running IPv4:

You need to let ICMP traffic through the firewall as well (IPv6 can resolve host names regardless of the firewall, but your DTCPIng log indicates you are running IPv4).

I have struggled with the same error you see in DTCPing, and in my case it turned out to be triggered by the firewall blocking the ICMP traffic.

Mikkel Christensen