MSMQ-此计算机上尚未安装消息队列 [英] MSMQ - message queuing has not been installed on this computer

查看:660
本文介绍了MSMQ-此计算机上尚未安装消息队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个示例应用程序,以写入开发服务器上的公共和私有队列.我没有在本地计算机上安装消息队列.

I have written a sample application to write to a public and private queues that are on dev server. I don't have the message queue installed on my local machine.

我收到错误消息:这台计算机上尚未安装消息队列.

I am getting error: message queuing has not been installed on this computer.

此行出现错误:

MessageQueue.Exists(queueName)

这里是完整的测试代码,所有已注释和未注释的私有和公共队列均导致相同的错误.我在这里做错什么了?

Here is the full test code, all commented and not commented private and public queues are resulting in the same error. What am i doing wrong here?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Messaging;

namespace MsmqTest
{
    public partial class Form1 : Form
    {
        //@"DIRECT=OS:devbox01\PRIVATE$\PrivateQueueDev";
        //@"DIRECT=TCP:192.168.6.102\PRIVATE$\PrivateQueueDev";
        private const string QueueName = @"DIRECT=TCP:192.168.6.102\PRIVATE$\PrivateQueueDev";


        //@"DIRECT=OS:devbox01\PublicQueueDev";
        //@"DIRECT=TCP:192.168.6.102\PublicQueueDev";
        private const string QueueNamePublic = @"DIRECT=TCP:192.168.6.102\PublicQueueDev";

        public Form1()
        {
            InitializeComponent();
        }

        private void Write_Click(object sender, EventArgs e)
        {
            MessageQueue msgQ;
            string msgText = String.Format("Message: {0}", DateTime.Now);
            try
            {
                msgQ = GetQ(QueueNamePublic);
                msgQ.Send(msgText);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        private void Read_Click(object sender, EventArgs e)
        {

        }

        private MessageQueue GetQ(string queueName)
        {
            MessageQueue msgQ;

            if(!MessageQueue.Exists(queueName))
            {
                try
                {
                    msgQ = MessageQueue.Create(queueName);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error creating queue", ex);
                }
            }
            else
            {
                try
                {
                    msgQ = new MessageQueue(queueName);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error getting queue", ex);
                }
            }
            return msgQ;
        }

    }
}

推荐答案

您需要

You need to install MSMQ on ALL machines which want to participate in the transmission and reception of messages. That includes sending machines such as your local machine in this instance.

其原因是由于MSMQ使用的存储转发消息传递模式.

The reason for this is because of the store-and-forward messaging pattern that MSMQ uses.

http://en.wikipedia.org/wiki/Store_and_forward

当您向服务器发送"消息时实际发生的事情是:

What is actually happening when you "send" a message to your server is:

  1. 本地队列管理器将消息写入本地临时队列.
  2. 本地队列管理器连接到远程队列管理器.
  3. 消息已发送.
  4. 远程队列管理器将消息写入远程队列.

这篇关于MSMQ-此计算机上尚未安装消息队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆