Using JMS to connect to IBM MQ

后端 未结 5 2293
被撕碎了的回忆
被撕碎了的回忆 2020-12-28 21:49

I want to use JMS to connect to IBM MQ. How do i specify the queuemanager, the channel and other properties ?

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-28 22:06

    Using IBM client API

                import com.ibm.mq.MQEnvironment;
                import com.ibm.mq.MQQueue;
                import com.ibm.mq.MQQueueManager;
                import com.ibm.mq.constants.CMQC;
    
                public class QueueMonitoring {
    
                    public static void main(String[] args) {
                        int openOptions = CMQC.MQOO_INQUIRE | CMQC.MQOO_INPUT_AS_Q_DEF;
                        MQEnvironment.hostname = "192.168.59.103";
                        MQEnvironment.port = 1414;
                        MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
                        MQEnvironment.properties.put(CMQC.TRANSPORT_PROPERTY,CMQC.TRANSPORT_MQSERIES);
    
                        MQQueueManager qMgr;
                        try {
                            qMgr = new MQQueueManager("QM1");
                            MQQueue destQueue = qMgr.accessQueue("DOCKERQ", openOptions);
                            System.out.println("Queue size:" + destQueue.getCurrentDepth());
                            destQueue.close();
                            qMgr.disconnect();
    
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
    
                    }
                    }
    

提交回复
热议问题