检查MQ队列深度 [英] Check MQ queue depth

查看:3286
本文介绍了检查MQ队列深度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助在java中获取队列深度的代码。我们在IBM WebSphere MQ中有4个队列,其中有消息。

Can anyone help in doing the code in java of getting the depth of the queues. We are having 4 queues in IBM WebSphere MQ and inside them there are messages.

我想在运行报告时编写一个jsp来读取队列名称及其深度。
我该怎么办?

I want to write a jsp to read the queue names and their depth while running the report. How do I do that?

推荐答案

参见 http://blog.guymahieu.com/2008/06/11/getting-深入的mqseries-queue-from-java /

我重新实现了如下:

import com.ibm.mq.*;

public class QueueManager {

    private final String host;
    private final int port;
    private final String channel;
    private final String manager;
    private final MQQueueManager qmgr;

    public QueueManager(String host, int port, String channel, String manager) throws MQException {
        this.host = host;
        this.port = port;
        this.channel = channel;
        this.manager = manager;
        this.qmgr = createQueueManager();
    }

    public int depthOf(String queueName) throws MQException {
        MQQueue queue = qmgr.accessQueue(queueName, MQC.MQOO_INQUIRE | MQC.MQOO_INPUT_AS_Q_DEF, null, null, null);
        return queue.getCurrentDepth();
    }

    @SuppressWarnings("unchecked")
    private MQQueueManager createQueueManager() throws MQException {
        MQEnvironment.channel = channel;
        MQEnvironment.port = port;
        MQEnvironment.hostname = host;
        MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);
        return new MQQueueManager(manager);
    }
}

将以下jar放在类路径中:

Put the following jars on your classpath:


  • com.ibm.mq * jar

  • j2ee.jar

这篇关于检查MQ队列深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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