`

Websphere MQ2

 
阅读更多
package com.ibm.test; 
 
import java.io.IOException; 
 
import com.ibm.mq.MQC; 
import com.ibm.mq.MQException; 
import com.ibm.mq.MQGetMessageOptions; 
import com.ibm.mq.MQMessage; 
import com.ibm.mq.MQPutMessageOptions; 
import com.ibm.mq.MQQueue; 
import com.ibm.mq.MQQueueManager; 
 
public class MQSample { 
    //定义队列管理器和队列的名称  
    private static String qmName;  
    private static String qName; 
     
    /**
     * @param args
     */ 
    public static void main(String[] args) { 
         
         qmName ="QM_APPLE"; 
         qName = "Q1"; 
        System.out.println("QManager:"+qmName); 
        System.out.println("QueueName:"+qName); 
        try { 
            //定义并初始化队列管理器对象并连接   
            MQQueueManager qMgr = new MQQueueManager(qmName);  
 
            // 设置将要连接的队列属性  
            // Note. All WebSphere MQ Options are prefixed with MQC in Java.   
            @SuppressWarnings("deprecation") 
            int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;  
 
            //连接队列   
            MQQueue localQ = qMgr.accessQueue(qName, openOptions);  
             
            //定义一个简单的消息  
            MQMessage putMessage = new MQMessage();  
            putMessage.writeUTF("Hello World!");  
 
            //设置写入消息的属性(默认属性)  
            MQPutMessageOptions pmo = new MQPutMessageOptions();  
             
            //将消息写入队列   
            localQ.put(putMessage,pmo);  
                         
//            MQMessage retrievedMessage = new MQMessage();  
//            retrievedMessage.messageId = putMessage.messageId;   
//  
//            //设置取出消息的属性(默认属性)  
            // MQGetMessageOptions gmo = new MQGetMessageOptions();   
//  
//            // 从队列中取出消息  
//            localQ.get(retrievedMessage, gmo);   
//            String msgText = retrievedMessage.readUTF();  
 
//            System.out.println("The message is: " + msgText);   
 
            //关闭队列  
            localQ.close();  
            //从队列管理器断开   
            qMgr.disconnect();  
        }catch (MQException ex) {  
            System.out.println("A WebSphere MQ error occurred : Completion code "  
            + ex.completionCode + " Reason code " + ex.reasonCode);  
        }catch (IOException ex) {  
            System.out.println("An error occurred whilst writing to the message buffer: " + ex);  
        }catch(Exception ex){ 
            ex.printStackTrace(); 
        } 
 
    } 
 

分享到:
评论

相关推荐

    Websphere MQ入门教程

    第一部分 Websphere MQ原理和体系结构 11 第一章Websphere MQ原理 11 目标 11 1.1中间件 11 1.1.1中间件的优点 11 1.1.2中间件的分类 12 1.2三种通信技术的比较 13 1.3 WebSphere MQ的原理 15 1.4 WebSphere MQ的...

    IBM WebSphere MQ 安装包

    IBM WebSphere MQ是IBM业界领先面向消息的中间件产品,也是MQ系列产品的基础和核心,它使不同的应用程序能够以企业级的性能,在广泛的平台上安全而可靠地通讯。

    WebSphere MQ自学笔记

    本人自学IBM的WebSphereMQ自学笔记,内有MQ安装文档,建MQ的例子等。 1、 MQ6.0安装 2 1.1 启动MQ v6.0 安装程序 2 1.2 软件需求检查 2 1.3 WebSphere Eclipse Platform V3.0.1软件安装 2 1.4 网络配置检查 3 1.5 ...

    Websphere MQ入门教程7

    全书共分为3部分共14章,第一部分 WebSphere MQ原理和体系结构,分为两章;第二部分 WebSphere MQ系统管理,分为六章,分别介绍安装、配置、管理、控制命令和问题确定;第三部分 WebSphere MQ应用开发,由五章组成,...

    WebSphereMQ_V7.5.0.2_for_Windows(4-1)

    WebSphere® MQ (也称MQSeries)以一致的、可靠的和易于管理的方式来连接应用程序,并为跨部门、企业范围的集成提供了可靠的基础。通过为重要的消息和事务提供可靠的、一次且仅一次的传递,Websphere MQ 可以处理...

    非常全面的WebsphereMQ的PDF学习资料

    个人收集整理,非常全面的WebsphereMQ的PDF学习资料。Websphere MQ Programming Guide,Websphere MQ Using C++,WebSphere MQ Using Java,WEBSPHERE MQ6.0 JAVA编程,WebSphere MQ基础教程,IBM WEBSPHERE MQ教程...

    WebSphereMQ_V7.5.0.2_for_Windows.part2.rar

    WebSphere® MQ (也称MQSeries)以一致的、可靠的和易于管理的方式来连接应用程序,并为跨部门、企业范围的集成提供了可靠的基础。通过为重要的消息和事务提供可靠的、一次且仅一次的传递,Websphere MQ 可以处理...

    WebSphere MQ 开发培训

    WebSphere MQ 开发培训 IBM软件部 软件部 WebSphere MQ 议程 WebSphere MQ 概览 WebSphere MQ 安装配置 WebSphere MQ 应用开发 WebSphere MQ 参考

    IBM Websphere mq安装

    IBM Websphere mq安装IBM Websphere mq安装

    IBM Websphere MQ 教程之备份与恢复

    IBM Websphere MQ 教程之备份与恢复

    WebSphere MQ

    WebSphere MQ WebSphere MQWebSphere MQ WebSphere MQ

    WebSphere MQ V7.0 jar

    WebSphere_MQ_V7.0.1.3 安装目录下\java\doc;\java\lib;\java\lib64. 包含com.ibm.mq.jar,com.ibm.mq.jmqi.jar,com.ibm.mq.axis2.jar,com.ibm.mq.commonservices.jar等等

    IBM WebSphere MQ 8.0 linux 安装包 part3

    IBM WebSphere MQ 8.0 linux 安装包 part3,IBM WebSphere MQ 8.0 linux 安装包 part3

    IBM Websphere MQ 培训课程2

    IBM Websphere MQ 培训课程2 MQ7教程实验

    IBM WebSphere MQ 简介和概述

    WebSphere MQ 所能解决的业务问题的种类,并了解 WebSphere MQ 如何能够帮助您满足业务要求。

    IBM Websphere MQ入门教程.doc

    2, 介绍WebSphere MQ的原理。 3, 介绍WebSphere MQ的特性和优点。 1.1中间件 中间件处于应用软件和系统软件之间,是一种以自己的复杂换取企业应用简单化的可复用的基础软件。在中间件产生以前,应用软件直接使用...

    websphere mq常用命令

    websphere mq常用命令 websphere mq常用命令

    IBM WebSphere MQ 8.0windows安装包 part2

    IBM WebSphere MQ 8.0windows安装包 part2

    WebSphere MQ工作原理

    消息中间件及WebSphere MQ入门,介绍WebSphere MQ工作原理,消息队列技术,MQ的基本概念,MQ的通讯模式

Global site tag (gtag.js) - Google Analytics