MSMQ初探

There are two main ways to set up Microsoft Message Queue Server (MSMQ) 2.0 on a Windows 2000 computer - Workgroup or Directory mode. This is determined when configuring MSMQ for the first time. To determine whether your MSMQ 2.0 is configured in Workgroup or Directory mode, check the following registry subkey: HKLM\SOFTWARE\Microsoft\MSMQ\Parameters A value named "Workgroup" with a value of 1 (0x1) indicates that MSMQ 2.0 was installed in Workgroup mode.

MSMQ有两种安装方式(Workgroup,Directory mode),两种模式的区别见底部参考链接 在win10环境下查看注册表路径:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSMQ\Parameters\Workgroup

Being part of a domain is a pre-cursor for installing MSMQ in AD-integrated mode. It doesn't guarantee MSMQ IS installed in AD-integrated mode. MSMQ will install in workgroup mode if:

  • AD integration was not selected as a setup option
  • AD integration was selected but failed to initialise; check event logs

如上所述,MSMQ的安装模式会默认为workgroup,不过我在安装的时候已经勾选了MSMQ节点下的所有选项,但是显示的还是workgroup模式 当我尝试使用自有代码新建、操作message queue时,会遇到如下错误:

A workgroup installation computer does not support the operation.

这表明我尝试使用AD模式下才能有的特性,比如:

公共队列必须在Active Directory模式下使用。因此是无法使用类似MessageQueue.GetPublicQueues()获取公共队列

所以如果你也是workgroup模式,发现网上或者书上例子跑不通的话,都可以尝试去操作私有的队列,这里有个操作不同类型队列的路径表还是比较有用:

队列类型语法
公有队列MachineName\QueueName
私有队列MachineName\Private$\QueueName
日志队列MachineName\QueueName\Journal$
计算机日志队列MachineName\Journal$
计算机死信队列MachineName\DeadLetter$
计算机事务死信队列MachineName\XactDeadLetter$
string path = @".\private$\MyNewPrivateQueue";
if (MessageQueue.Exists(path))
{
     var queue = new MessageQueue(path);
     Console.WriteLine("open existing queue");
     Console.WriteLine(queue.Label);
     queue.Send("Sample Message", "Label");
}
else
{
     Console.WriteLine("Queue not existing");
     var queue = MessageQueue.Create(path )
}

另外还可以使用Format方式打开队列

new MessageQueue(@"FormatName:Public=xxx-xx--xxx.....")

参考: Why does MSMQ think I'm on a workgroup computer?

How to determine if MSMQ 2.0 is installed in Workgroup or Directory mode

MSMQ

Information about Workgroup mode and about Domain mode in Microsoft Message Queuing

转载于:https://my.oschina.net/u/588339/blog/662525

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值