需要访问MQ 7的队列深度 [英] Need to Access the Queue depth of MQ 7

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

问题描述

我的下面是该代码在MQ6上运行良好,但对于MQ7,它给出了例外情况

My Below is the code works good with MQ6 but for MQ7 its giving exception

'package javaapplication1;

import java.io.*;
import java.net.*;
import java.util.*;
import java.util.TimerTask;
 import com.ibm.mq.MQEnvironment;
import com.ibm.mq.MQException;
    import com.ibm.mq.MQQueue;
    import com.ibm.mq.MQQueueManager;
    import com.ibm.mq.constants.CMQC;
class Connectivity 
{
    public static void main(String args[]) throws MQException
    {
       String qManager="";
       int port_num=0;
    int openOptions =  CMQC.MQOO_FAIL_IF_QUIESCING + CMQC.MQOO_INPUT_SHARED;

    MQEnvironment.hostname = "Host_name";
    MQEnvironment.port = port_num;
    MQEnvironment.channel = "Chn_name";
    System.out.println("Connecting to queue manager: " + qManager);
            Hashtable props = new Hashtable();

            // Change the host name to your host name. Leave it as it is if 
            // queue manager is on the same machine
            props.put(CMQC.HOST_NAME_PROPERTY, "Host_name"); 
            props.put(CMQC.PORT_PROPERTY, port_num);
            props.put(CMQC.CHANNEL_PROPERTY, "Chn_Name");

            MQQueueManager qMgr = new MQQueueManager(qManager, props);
    //MQQueueManager qMgr = new MQQueueManager("SW1_QM");

    MQQueue destQueue = qMgr.accessQueue("Q_Name",   openOptions);

    System.out.println("E_RETRY size:" + destQueue.getCurrentDepth());
    destQueue.close();
    qMgr.disconnect();
    }


}'

我在行上遇到异常

'System.out.println("E_RETRY size:" + destQueue.getCurrentDepth());'

'System.out.println("E_RETRY size:" + destQueue.getCurrentDepth());'

,异常消息是

'MQJE001: Completion Code 1, Reason 2068
Exception in thread "main" com.ibm.mq.MQException: MQJE001: Completion Code 1, Reason 2068
    at com.ibm.mq.MQManagedObject.inquire(MQManagedObject.java:257)
    at com.ibm.mq.MQManagedObject.getInt(MQManagedObject.java:428)
    at com.ibm.mq.MQQueue.getCurrentDepth(MQQueue.java:1478)
    at javaapplication1.Connectivity.main(Connectivity.java:36)
Java Result: 1'

请帮助我.

推荐答案

您的打开选项不包含MQOO_INQUIRE,这是获取队列深度所必需的.我期望使用MQRC 2038,因为未指定MQOO_INQUIRE选项.

Your open option does not include MQOO_INQUIRE which is a must for getting queue depth. I expected a MQRC 2038 because MQOO_INQUIRE option was not specified.

不确定为什么还要初始化MQEnvironment并将属性哈希表传递给MQQueueManager构造函数.

Not sure why you are initializing MQEnvironment also and you are passing a properties hash table to MQQueueManager constructor.

无论如何,这里是获取本地队列的队列深度的示例代码.

Anyway here is the sample code that gets queue depth for a local queue.

public static void getQueueDepth()
{
            String qManager="QM1";
    int port_num=1414;
    int openOptions =  CMQC.MQOO_FAIL_IF_QUIESCING + CMQC.MQOO_INPUT_SHARED + CMQC.MQOO_INQUIRE;

    try {
            Hashtable props = new Hashtable();

            props.put(CMQC.HOST_NAME_PROPERTY, "localhost"); 
            props.put(CMQC.PORT_PROPERTY, port_num);
            props.put(CMQC.CHANNEL_PROPERTY, "SYSTEM.DEF.SVRCONN");

            MQQueueManager qMgr = new MQQueueManager(qManager, props);

            MQQueue destQueue = qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",   openOptions);

            System.out.println("E_RETRY size:" + destQueue.getCurrentDepth());
            destQueue.close();
            qMgr.disconnect();
    }catch(MQException mqe){
        System.out.println(mqe);
    }
}

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

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