bash 我们可以使用脚本语言检查队列深度吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12040808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 03:04:44  来源:igfitidea点击:

Can we check the queue depth using a scripting language?

javaperlbashshellibm-mq

提问by gyani

Is it feasible to check queue depth(MQ) using any scripts? [No restrictions on the language]. The plan is to look at non-Java solutions.

使用任何脚本检查队列深度(MQ)是否可行?[无语言限制]。计划是研究非 Java 解决方案。

I do understand that it is achievable in Java using MQQueueManager but that would need the usage of client API. Hence checking for any alternate options or better practices.

我知道它可以在 Java 中使用 MQQueueManager 实现,但这需要使用客户端 API。因此,检查任何替代选项或更好的做法。

InquireQueue at http://www.capitalware.biz/mq_code_perl_python.htmllooks similar[but looks a bit outdated]

http://www.capitalware.biz/mq_code_perl_python.html 上的InquireQueue看起来很相似[但看起来有点过时]

采纳答案by Roger

Didn't Google give you a recent blog posting I wrote called "How to Clear a MQ Queue from a Script or Program" at http://www.capitalware.biz/rl_blog/?p=1616

谷歌没有给你我最近在http://www.capitalware.biz/rl_blog/?p=1616 上写的一篇名为“如何从脚本或程序中清除 MQ 队列”的博客文章

Just change the MQSC "clear" command to "current depth" (CURDEPTH). i.e.

只需将 MQSC“清除”命令更改为“当前深度”(CURDEPTH)。IE

DIS QL(TEST.*) CURDEPTH

回答by Brian Crabtree

Does nobody use google anymore ?

没有人使用谷歌了吗?

PyMQI, an open-source Python extension for WebSphere MQ

PyMQI,WebSphere MQ 的开源 Python 扩展

http://metacpan.org/pod/MQSeries::Queue

http://metacpan.org/pod/MQSeries::Queue

my %qattr = $queue->Inquire( qw(MaxMsgLength MaxQDepth) );

我的 %qattr = $queue->Inquire(qw(MaxMsgLength MaxQDepth));

回答by Thomas Vincent

The perl mqseries is very complete. Below is some sample code. (Part of the credit for the sample probably goes to someone else, but it has been floating around my drive for years.) The code connects to the queue manager specified by the command line, if not supplied, it will connect to the default queue manager. It then inquires about the queue name passed in, specifically, the current depth of that queue. This is displayed to the user. This code can easily be modified to display other queue properties. Furthermore, MQINQ can be used to inquire about the attributes of other objects, not just queues.Here is the subset sample code:

perl mqseries 非常完整。下面是一些示例代码。(示例的部分功劳可能归功于其他人,但它已经在我的驱动器中漂浮多年。)代码连接到命令行指定的队列管理器,如果未提供,它将连接到默认队列经理。然后查询传入的队列名称,特别是该队列的当前深度。这是向用户显示的。可以轻松修改此代码以显示其他队列属性。此外,MQINQ 可用于查询其他对象的属性,而不仅仅是队列。 下面是子集示例代码:

use MQSeries;

my $quename = $ARGV[0];
my $quemgrname = $ARGV[1];

my $Hconn = MQCONN($qmgrname, $CompCode, $Reason);
print"MQCONN reason:$Reason\n";

my $ObjDesc = { ObjectType => MQOT_Q, ObjectName => $qname };

my $Options = MQOO_INQUIRE | MQOO_SET | MQOO_FAIL_IF_QUIESCING;
my $Hobj = MQOPEN($Hconn,$ObjDesc,$Options,$CompCode,$Reason);
print"MQOPEN reason:$Reason\n";

my $tst = MQINQ($Hconn,$Hobj,$CompCode,$Reason,MQIA_CURRENT_Q_DEPTH);
print"Depth of $qname is: $tst\n";

MQCLOSE($Hconn,$Hobj,$COptions,$CompCode,$Reason);
print"MQCLOSE reason:$Reason\n";
MQDISC($Hconn,$CompCode,$Reason);
print"MQDISC reason:$Reason\n";

回答by Piyush Yadav

If you are logged in using MQM user on linux and want to have a quick check on queues with messages in them .. here is a quickfix ..

如果您在 linux 上使用 MQM 用户登录并希望快速检查队列中的消息..这里是一个快速修复..

echo "dis ql(*) CURDEPTH" | runmqsc <QMGRNAME> | grep -v '(0' | grep -v 'AMQ'

this will give you a command line output and you can schedule the same command in crontab if needed directly ( without having to save a script for it )

这将为您提供命令行输出,如果需要,您可以直接在 crontab 中安排相同的命令(无需为其保存脚本)

I know its not neat but may be the quickest of solutions.

我知道它不整洁,但可能是最快的解决方案。

回答by slim

There's the many JVM based scripting/ish languages that give you access to Java classes. Some need a thin glue layer, some need nothing at all.

有许多基于 JVM 的脚本/ish 语言可让您访问 Java 类。有些需要薄薄的胶水层,有些则根本不需要。

  • Groovy
  • Jython
  • Scala
  • Clojure
  • etc.
  • 常规
  • Jython
  • 斯卡拉
  • Clojure
  • 等等。