C# – MSMQ Send message to Remote Queue

cmsmq

I am trying to send a message to a remote queue. My process isn't failing, but I still don't see the message on the remote queue? I would assume it would fail if it couldn't process the message?

I did notice that on my local machine the remote queue is listed in Outgoing queues, but don't see messages there either. Very ignorant here and all examples show that how I am doing (or so I assume) is correct.

Code (Simple for test):

    using (var transaction = new TransactionScope())
    {
        using (var queue = new MessageQueue(@"FormatName:DIRECT=OS:mymachine\MyQueueQueue"))
        {
            XDocument xdoc = XDocument.Parse("<root/>");

                 var message = new Message(xdoc.ToString());
                queue.Send(message, MessageQueueTransactionType.Single);
        }

        transaction.Complete();
    }

    Console.Read();
}

What I am doing wrong? Strange…no errors, but don't see message anywhere. Write works to my local queue.

Best Answer

The queue you see on your local machine is how MSMQ transmits a message from your machine to the remote machine. So don't worry about that as long as there are no messages on it. If there were messages on it that would indicate the remote queue was not available for some reason.

Likely permissions could an issue. Check the send permissions on the remote queue. If the call is going cross-domain you will need to add ANONYMOUS LOGON to your permissions.

Also try to enable to MSMQ event log (if you are running server 2008 or above).

UPDATE

It looks like you are calling a public queue address. You should be using private queues. The address is the same except for the PRIVATE$ directive:

FormatName:DIRECT=OS:mymachine\PRIVATE$\MyQueueQueue

ALSO: is your queue name myQueueQueue like in your queue address?

Related Topic