Need to Access the Queue depth of MQ 7

后端 未结 2 1819
夕颜
夕颜 2021-01-24 17:24

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.*;
i         


        
相关标签:
2条回答
  • 2021-01-24 18:24

    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.

    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);
        }
    }
    
    0 讨论(0)
  • 2021-01-24 18:27

    Is it possible the properties of the queue are different between the v6 and v7 queue managers? The documentation for the error message indicates this can occur with a cluster queue that resolves to a remote instance of the queue.

    Have you verified that destQueue is in fact a valid queue?

    0 讨论(0)
提交回复
热议问题