繁体   English   中英

如果我的MessageQueue是私有的,我的机器可以从另一台本地机器读取消息吗?

[英]Can my machine read messages from another local machine if my MessageQueue is private?

我想从本地网络上的另一台计算机接收消息,因此我以这种方式创建了MessageQueue

private static string QueueName = ".\\Private$\\Q1";
    public void SendMessage()
    {           
        if (!MessageQueue.Exists(QueueName))
            MessageQueue.Create(QueueName);

        //
    }

    public void ReceiveMessage()
    {
        // Connect to the a queue on the local computer.
        MessageQueue myQueue = new MessageQueue(QueueName);

        // Set the formatter to indicate body contains an Order.
        myQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(Queue.Order) });

        try
        {
            // Receive and format the message. 
            Message myMessage = myQueue.Receive();
            ///
    }

我还尝试使用@"MachineName\\QueueName"格式创建我的MessageQueue ,但是收到了MessageQueueException。

如果转到“计算机管理”并在“服务和应用程序”>“消息队列”>“专用队列”下查看,您是否看到名为“ Q1”的队列? 如果是这样,其中是否有任何消息? 您可能需要调整队列上的属性(右键单击>属性>安全性)。 如果您处于开发环境中,则可以先授予“所有人”完全控制权。 工作正常后,尝试找出最小权限集。 您可能还想从计算机管理mmc创建队列,而不是从代码中创建队列。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM