我看网上的帖子都设置了MQEnvironment.channel,请问这个是必须要设置的吗?在下面的程序中没调用这个变量啊。

解决方案 »

  1.   

    我也用过IBMMQ,这个是我的测试代码,你看看和你的有什么不同:
    import com.ibm.mq.*;public class MQSample {
        public static void main(String args[]) {
            new MQSample();
        }    public MQSample() {
            MQEnvironment.hostname = "100.0.0.76";
            MQEnvironment.channel = "dayangChannel";    //通道
            MQEnvironment.port = 1414;
            MQEnvironment.CCSID = 1381;  //字符集
            try {
                System.out.println("==============1");
                MQQueueManager qMgr = new MQQueueManager("dayangmam");
                System.out.println("==============2");
                int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE;
                MQQueue queue = qMgr.accessQueue("dayangQueue", openOptions);
                MQMessage hello_world = new MQMessage();
                hello_world.writeUTF("Hello World!sssssssss中国");
                MQPutMessageOptions pmo = new MQPutMessageOptions();
                queue.put(hello_world, pmo);
                queue.close();
                qMgr.disconnect();
            } catch (Exception e) {
                StackTraceElement ss[] = e.getStackTrace();
                for (int i = 0; i < ss.length; i++) {
                    System.out.println(ss[i]);
                }
            }
        }
    }
      

  2.   

    9月25日,邱丰聊“松耦合通讯中间件MQ数据交换研究”http://bbs.csai.cn/bbs/view.asp?Id={F8BCF2EF-3510-4BAD-A17E-7041931DB484}