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

本文关键字:机器 我的 消息 读取 一台 MessageQueue 如果 是否 | 更新日期: 2023-09-27 18:32:31

我想从本地网络上的另一台计算机接收消息,所以我以这种方式创建了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。

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

如果您转到"计算机管理"并在"服务和应用程序"下查看"消息队列">"专用队列">,您是否看到名为"Q1"的队列? 如果是这样,里面是否有任何消息? 您可能需要调整队列上的属性(右键单击"属性">"安全性">)。 如果你处于开发环境中,则可以首先授予"每个人完全控制"权限。 一旦你让它工作,试着找出最低权限集。 您可能还希望从计算机管理 mmc 创建队列,而不是在代码中创建队列。

相关文章: