windows自带消息队列Message Queues的使用

发布时间 2023-03-30 16:48:08作者: love/coder

1、安装

控制面板-》程序和功能-》启用或关闭windows功能-》Microsoft消息队列服务器-》选中安装

2、编程存取队列消息(一般是专有队列)

String mqname = @".\private$\orderMQ";
 
     if (!MessageQueue.Exists(mqname))
     {
       MessageQueue.Create(mqname);
     }
 
     MessageQueue que = new MessageQueue(mqname);
     que.Formatter = new BinaryMessageFormatter();
 
     while (true)
     {
       using (Message msg = que.Receive())
       {
         String str = (String) msg.Body;
         Console.WriteLine("Received: {0}", str);
       }
     }

3、查看

计算机-》右键管理-》服务和应用程序-》消息队列-》

 

 

 

4、作用

用作消息队列信息缓存,程序异步解耦、处理并发无关联业务、耗时业务等

 

5、流程

判断队列存在;

新建队列关联对象;

存数据;

取数据;

事务,标记,同步异步;

 

https://www.cnblogs.com/Clingingboy/archive/2010/08/26/1809587.html

Message Queuing(MSMQ) - Hirsinkai - 博客园 (cnblogs.com)