Search code examples
c#.netmsmq

How to read MSMQ messages from a remote machine without installing message queueing on local machine?


There is a remote machine (let's call it MSMQ machine) which has MSMQ installed on it and is used by several other processes. I would like to read the messages on a given private queue of the MSMQ machine from my local machine - BUT, I would like to avoid installing Message Queuing on my machine, since what I need is simply to check and monitor the messages. I will not send nor receive messages (at least won't store them), I just want to "peek" at them.

Is there any way to do this? I have a code more a less like this now:

public string CheckMessageQueue(machine, queue)
{
    StringBuilder Ret = new StringBuilder();
    var path = machine "\Private$\" + queue;
    try
    {
        MessageQueue mq = new MessageQueue(path);
        Message msg = new Message();
        msg = mq.Peek();
        Console.WriteLine(msg.ToString());
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

if I run the code above I get the error message

"Message Queuing has not been installed on this computer."


Solution

  • No, there is no other way than installing MSMQ on your local machine as well. The client libraries uses the local server to communicate with remote servers.