使用JScript窥视MSMQ外发队列 [英] Peeking an MSMQ Outgoing Queue with JScript

查看:106
本文介绍了使用JScript窥视MSMQ外发队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个脚本来监视一组队列,尽管该脚本与远程专用队列完美配合,但不适用于发送队列.我通过从脚本中删除除基本内容以外的所有内容进行了实验,并创建了以下测试脚本:

I created a script to monitor a set of queues, and, while it works perfectly with Remote Private Queues, it doesn't work with Outgoing Queues. I made an experiment by removing everything but the essential from the script, and I created the following test script:

var info = new ActiveXObject("MSMQ.MSMQQueueInfo");
info.FormatName = /*<Queue name>*/;

// 0x80 = MQ_ADMIN_ACCESS
// 0x20 = MQ_PEEK_ACCESS
// 0x00 = MQ_DENY NONE
var mq = info.Open(0x80 | 0x20, 0x00);

var msg = mq.PeekCurrent(false, true, 0); 
if (msg != null) {
    WScript.echo("message found");  
}
else
{
    WScript.echo("Nothing");
}
mq.close();

然后我在服务器上运行它,即使队列中包含一千多条消息, PeekCurrent 始终返回null.如果删除MQ_ADMIN_ACCESS,它将尝试连接到远程专用队列,并且超时(按预期,因为它允许消息累积).如果再启动远程专用队列",它将从中正确读取消息.

I then ran it on the server and, even if the queue contains over a thousand messages, PeekCurrent always returns null. If I remove MQ_ADMIN_ACCESS it tries to connect to the Remote Private Queue and it times out (as expected, as it's down to let messages cumulate). If I then start the Remote Private Queue, it reads the message correctly from it.

出于好奇,我发现使用MQ_ADMIN_ACCESS时,不管队列名称(即是否存在), info.Open 总是成功.例如,我键入"DIRECT = OS:Whatever \ private $ \ RandomQueueName",但没有收到任何错误.

Out of curiosity, I found out that info.Open always succeeds no matter the Queue Name (i.e. whether it exists or not) when MQ_ADMIN_ACCESS is used. For example, I typed "DIRECT=OS:Whatever\private$\RandomQueueName", and I didn't get any error.

我不是MSMQ的专家(恰恰相反),所以我可能犯了一个明显的错误,我看不到它.任何帮助都超过了欢迎.谢谢.

I'm not an expert of MSMQ (quite the opposite), so I'm probably making an obvious mistake and I can't see it. Any help is more than welcome. Thanks.

其他问题:是否可以窥视远程外发队列?目前,该脚本正在我正在测试的发送队列"所在的计算机上运行,​​但并非只有这些队列.我想避免将脚本部署到任何地方,我希望将其放在一个位置.谢谢.

Side question: is it possible to peek a Remote Outgoing Queue? At the moment the script is running on the machine where the Outgoing Queue I'm testing is located, but it's not the only one with these queues. I'd like to avoid deploying the script everywhere, I'd prefer to have it in a single place. Thanks.

推荐答案

我找到了两个问题的答案:

I found the answers to both my questions:

  • 我遇到的问题是由于以下事实:当脚本在当前控制台会话下运行时,我试图监视作为群集资源组一部分运行的MSMQ队列.要访问群集资源组中的队列,必须执行以下操作:

  • The issue I was having was due to the fact that I tried to monitor an MSMQ Queue which was running as part of a Cluster Resource Group, while the script was running under the current Console Session. To access a Queue inside a Cluster Resource Group, the following must be done:

  1. 创建一个新的通用应用程序
  2. 运行MSMQ服务的组中的资源,并将其指向您的脚本.
  3. 在新资源的配置中,添加MSMQ服务作为依赖项.
  4. 请确保已选中使用网络名称作为计算机名称"复选框.

完成后,您的脚本现在将连接到群集组中运行的MSMQ服务.

Done, your script will now connect to the MSMQ Service running inside the Cluster Group.

  • 传出队列不是真正的队列,但可以看作是邮件列表,按邮件发往的队列分组".因此,不能对其进行远程监视.这意味着,要监视它们,必须在每台计算机上部署执行该脚本/应用程序的脚本/应用程序,并且在群集环境中,必须在每个群集组中运行一个实例.如果有许多服务器,这会增加大量开销,但是可以通过创建集中式系统来克服.反正还是大任务...

我希望我的发现对将来的人有用. :) 回到比萨烤...

I hope my findings will be useful to somebody in the future. :) Back to pizza baking...

这篇关于使用JScript窥视MSMQ外发队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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