Java program MQ 7 connection issue

三世轮回 提交于 2019-12-11 20:17:16

问题


I am trying to connect to the MQ7 Server below is the code :

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, serverConfig.server); 
        props.put(CMQC.PORT_PROPERTY, serverConfig.port);
        props.put(CMQC.CHANNEL_PROPERTY, serverConfig.sChannel);

        qMgr = new MQQueueManager(qManager, props);
        System.out.println("Queue Manager : "+qMgr+" null");

        int openOptions = MQC.MQOO_INPUT_AS_Q_DEF
                | MQC.MQOO_OUTPUT |  MQC.MQOO_INQUIRE;

        queue = qMgr.accessQueue(queueName, openOptions);

        System.out.println("Successfully registered");

        //creating msg
        message = new MQMessage();

it's getting connected but after sending one message its throwing a error

" MQJE001: Completion Code '1', Reason '2068'.
com.ibm.mq.MQException: MQJE001: Completion Code '1', Reason '2068'.
strngError: No valid counters.
strngError: No valid counters.
    at com.ibm.mq.MQManagedObject.inquire(MQManagedObject.java:269)
    at com.ibm.mq.MQManagedObject.getInt(MQManagedObject.java:479)
    at com.ibm.mq.MQQueue.getCurrentDepth(MQQueue.java:995)
    at middlewarex.IBMmq.getQueueCount(IBMmq.java:227)
    at middlewarex.ThreadScenario.run(ThreadScenario.java:94)
    at java.lang.Thread.run(Thread.java:722)

pointing on the line

" public long getQueueCount() throws Exception{
            return queue.getCurrentDepth();
        } "

Kindly Help me


回答1:


Did you look up Reason Code 2068 in the manual? Because if you did, you would have seen that using option MQOO_INQUIRE is invalid.

Secondly, why are you opening the queue for BOTH putting and getting messages? This is a VERY bad practice. You say you are sending (putting) a message to a queue, therefore, you should be opening the queue for output only.




回答2:


Due to firewall I was facing the exception when sending the message. Please try telnet and check whether the firewall is blocking you from accessing the machine.



来源:https://stackoverflow.com/questions/20290053/java-program-mq-7-connection-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!