【问题标题】:Need to Access the Queue depth of MQ 7需要访问 MQ 7 的队列深度
【发布时间】:2013-12-16 11:57:30
【问题描述】:

我的以下代码适用于 MQ6,但对于 MQ7,它会给出异常

'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());'

异常消息是

'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'

请帮帮我..

【问题讨论】:

    标签: java message-queue ibm-mq mq


    【解决方案1】:

    您的开放选项不包括MQOO_INQUIRE,这是获取队列深度所必需的。我期望 MQRC 2038,因为未指定 MQOO_INQUIRE 选项。

    不知道为什么还要初始化 MQEnvironment 并且要将属性哈希表传递给 MQQueueManager 构造函数。

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

    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);
        }
    }
    

    【讨论】:

    • Shashi.. 正如你所说.. 我这样使用 -- int 'openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE; ' 它在深度上显示错误.. 好的,我会在星期一尝试并回复你。感谢您的回复。
    • 我尝试使用您的代码,它给了我同样的异常.. 在互联网上搜索之后.. 我添加了几个 open_options int openOptions = CMQC.MQOO_FAIL_IF_QUIESCING + CMQC.MQOO_INPUT_SHARED + CMQC.MQOO_INQUIRE+CMQC.MQOO_BROWSE; System.out.println("E_RETRY size:" + destQueue.getCurrentDepth());但仍然给出了同样的异常.. 错误 -- 代码 -- @ 987654324@
    • 其实 Shashi .. 代码在 MQ6 上运行良好,即查找队列深度.. 但是当我尝试查找 MQ 7 时它显示异常..
    • 我强烈建议您联系 IBM 支持来解决问题。我没有看到您面临的问题。您的环境似乎有些不同。
    【解决方案2】:

    v6 和 v7 队列管理器的队列属性是否可能不同? documentation for the error message 表示这可能发生在解析为远程队列实例的集群队列中。

    您是否验证过 destQueue 实际上是一个有效队列?

    【讨论】:

    • 嘿..我检查了那个链接,我在我的程序int openOptions = CMQC.MQOO_FAIL_IF_QUIESCING + CMQC.MQOO_INPUT_SHARED + CMQC.MQOO_INQUIRE+CMQC.MQOO_BROWSE; 中添加了open_options,但仍然指向同一行..System.out.println("E_RETRY size:" + destQueue.getCurrentDepth());错误--代码--MQJE001: Completion Code 1, Reason 2068 com.ibm.mq.MQException: MQJE001: Completion Code 1, Reason 2068 –
    猜你喜欢
    • 1970-01-01
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-16
    • 1970-01-01
    相关资源
    最近更新 更多