.net 封装ActiveMQ消息队列 类库

ActiveMQ消息队列 就不具体解释了,代码就直接粘贴了 调用方法如下:

1 配置web.config

  <configSections>
    <section name="MQConfig" type="GWT.Framework.Common.MQ.Parameter.MQConfigInfo, GWT.Framework.Common.MQ"/>
  </configSections>
 <MQConfig ConnectUrl="tcp://localhost:61616" UserName="admin" Pwd="admin" ClientID="a6afcdbbbe02440391407f64049fcd8e_OMS1" MQType="ActiveMQ">

  </MQConfig>


2 发送消息调用

 GWT.Framework.Common.MQ.Parameter.MQMessage<string> msg = new GWT.Framework.Common.MQ.Parameter.MQMessage<string>();
                msg.Body =$"发送第{i}个信息:"+this.richTextBox1.Text;

                GWT.Framework.Common.MQ.MQManagement.SendQueueMessage<string>("abc",msg);

3 接收消息调用

  public delegate void MyDelegate(GWT.Framework.Common.MQ.Parameter.MQMessage<string> msg);
        public bool Receive(GWT.Framework.Common.MQ.Parameter.MQMessage<string> msg)
        {
            this.richTextBox2.Invoke(new MyDelegate(RevMessage1),msg);
            return true;
        }
        public void RevMessage1(GWT.Framework.Common.MQ.Parameter.MQMessage<string> message)
        {
            this.richTextBox2.Text += string.Format(@"接收到:{0}{1}", message.Body, Environment.NewLine);
        }


        private void button2_Click(object sender, EventArgs e)
        {
            MQManagement.ReceiveQueueMessage<string>("abc", Receive);

        }


资源下载地址:https://download.csdn.net/download/zhaobao110/10421273

阅读更多

没有更多推荐了,返回首页