本文介绍了Java程序MQ 7的连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想连接到MQ7服务器下面是代码:
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)指向行
" public long getQueueCount() throws Exception{ return queue.getCurrentDepth(); } "请帮我
推荐答案您是否在手册中查找原因代码2068?因为如果您这样做,您会看到使用选项MQOO_INQUIRE无效。
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.
更多推荐
Java程序MQ 7的连接问题
发布评论