`

websphere MQ3

 
阅读更多
大纲:

         

Creating the queue manager

Creating the local queue

Putting a test message on the local queue

Verifying that the test message was sent


1.Creating the queue manager using WebSphere MQ Explorer
Start WebSphere MQ Explorer.
In the Navigator view, right-click the Queue Managers folder, then click New > Queue Manager. The Create Queue Manager wizard opens.
In the Queue Manager name field, type QM_APPLE.
Select the Make this the default queue manager check box.
Click Next twice to go to Step 3 of the wizard.
Ensure that Auto Start Queue Manager is selected.
Click Next to go to Step 4 of the wizard.
Ensure that the Create listener configured for TCP/IP check box is selected.
If the Finish button is not available, type another port number in the Listen on port number field. If the current value is 1414, try typing 1415 or 1416.
Click Finish.
Results
An icon representing this queue manager is displayed in the Queue Managers folder in the Navigator view of WebSphere MQ Explorer, and the queue manager automatically starts running after you create it, as shown in the following screen capture:


Creating the queue manager using MQSC
About this task
Open a command prompt, and follow these steps:
Create a default queue manager called QM_APPLE by typing the command:
crtmqm -q QM_APPLEMessages tell you that the queue has been created and that the default WebSphere MQ objects have been created.
Start this queue manager by typing the command:
strmqm

A message tells you when the queue manager has started.
Results
You have now created a queue manager with the name QM_APPLE. The next task is to create a local queue that this queue manager will manage.




2.Creating the local queue using WebSphere MQ Explorer
In the Navigator view, expand the Queue Managers folder.
Expand queue manager QM_APPLE.
Right click the Queues folder, then click New > Local Queue... The New Local Queue wizard opens.
In the Name field, type Q1
Click Finish.
Results
The new queue, Q1, is displayed in the Content view, as displayed in the following screen capture:


If the queue is not displayed in the Content view, click Refresh at the top of the Content view.

Creating the local queue using MQSC
About this task
Open a command prompt and follow these steps:
Enable MQSC commands by typing the command:
runmqsc

Type the following command:
define qlocal (Q1)

Messages tell you that the queue has been created and that the default WebSphere MQ objects have been created.
Stop MQSC by typing the command:
end

Results
You have now created a local queue called Q1. The next task is to put a test message to this newly created local queue.



   

3.Putting a test message on the queue using WebSphere MQ Explorer
   在Eclipse 中,创建如下类:
[java] view plaincopyprint?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(); 
        } 
 
    } 
 


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相关类。


4.Verifying that the test message was sent using WebSphere MQ Explorer
In the Navigator view, expand the Queue Managers folder, then expand QM_APPLE.
Click the Queues folder.
In the Content view, right-click Q1, then click Browse Messages.... The Message browser opens to show the list of the messages that are currently on Q1.
Double-click the last message to open its properties dialog.
Results
On the Data page of the properties dialog, the Message data field displays the content of the message in human-readable form, as shown in the following screen capture:


Verifying that the test message was sent using MQSC
About this task
The amqsget sample program is used to get the message back from the queue.
Open a command prompt and follow these steps:

Start the amqsget sample program:
On Windows®, type the following command:amqsget Q1
On Linux®, change to the /opt/mqm/samp/bin directory and type the following command: ./amqsget Q1
Results
The sample program starts, and your message is displayed along with any other messages on this queue. After a pause of 15 seconds, the sample ends and the command prompt is displayed again.

Congratulations! You have now completed this tutorial.


分享到:
评论

相关推荐

    IBM WebSphere MQ 安装包

    3. **版本信息**:这里提供的安装包为WS_MQ_V7.5.0.2_TRIAL_FOR_WINDOWS_ML,表明这是WebSphere MQ的7.5.0.2试用版,专为Windows平台设计。"ML"通常代表“Multilingual”,意味着该版本支持多语言。 4. **安装与...

    IBM WebSphere MQ入门教程.pdf

    IBM WebSphere MQ入门教程 IBM WebSphere MQ 是一种基于消息队列的中间件,用于实现不同的应用程序之间的异步通信。下面是对 IBM WebSphere MQ 的入门教程的总结,涵盖了 WebSphere MQ 的原理、体系结构、重要特点...

    IBM WebSphere MQ 技术白皮书.doc

    IBM WebSphere MQ 技术白皮书 IBM WebSphere MQ 技术白皮书是 IBM 公司发布的一份技术白皮书,旨在介绍 IBM WebSphere MQ 产品的技术特性、架构和价值。下面是根据白皮书的内容生成的相关知识点。 概述 在概述...

    MQ,websphere mq

    3. **高可用性**:通过集群和镜像队列技术,WebSphere MQ可以提供高可用性和故障切换能力,确保服务的连续性。 4. **安全性**:WebSphere MQ支持用户身份验证和访问控制,能对消息传输进行加密,保护数据安全。 5....

    websphere MQ 8.0 自带jar包

    WebSphere MQ 8.0 自带的 JAR 包是一组关键组件,它们构成了 IBM 的消息中间件解决方案,用于在不同应用程序之间可靠地传递数据。这些 JAR 文件位于 `WebSphere MQ\java\lib` 目录下,是开发、配置和运行与 ...

    WebSphereMQ_V7.5.0.2_for_Windows(4-1)

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

    Linux 上的 WebSphere MQ 开发快速入门

    3. 安装所需的 MQ 包及 Webster MQ Server。 使用 Java 应用程序开发 MQ 环境 本文将说明如何使用 WebSphere MQ Java API 创建两个示例 Java 应用程序:MQSend(用于向队列发送消息)和 MQGet(用于从队列接收消息...

    Websphere MQ入门教程-使用IBM Websphere MQ

    【标题】:“Websphere MQ入门教程-使用IBM Websphere MQ” 【正文】: IBM WebSphere MQ(原名MQSeries)是IBM提供的一款企业级的消息中间件产品,它允许不同应用程序、系统和网络在不同时区和平台之间交换消息。...

    IBM Websphere MQ入门教程

    IBM Websphere MQ入门教程 IBM Websphere MQ是IBM公司开发的一款消息队列中间件,旨在提供一个可靠的异步通信机制,实现不同应用程序之间的数据交换和集成。下面是该教程的知识点总结: 中间件的概念和优点 ...

    WebSphere MQ介绍教程

    3. 支持Web 2.0:与AJAX和REST接口相结合,WebSphere MQ可以桥接HTTP应用程序,提供了一个消息传输的骨干支持,可帮助改善用户体验,提升吞吐量最高至20%。 4. JMS性能提升:增强了JMS(Java消息服务)的性能,使得...

    WebSphere MQ 系统管理指南 6.0

    《WebSphere MQ 系统管理指南 6.0》是一份详尽的文档,旨在为IT专业人士提供关于IBM WebSphere MQ版本6.0的全面系统管理指导。此指南覆盖了WebSphere MQ的基础知识、配置、操作与维护,以及高级主题,如故障排除和...

    Websphere MQ入门教程

    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教程...

    Websphere MQ入门教程7

    【Websphere MQ入门教程7】是一本专为初学者和WebSphere MQ系统管理员及开发者设计的实用指南。全书涵盖了WebSphere MQ的基础知识、系统管理和应用开发等多个方面,旨在帮助读者深入理解这一消息中间件的工作原理和...

    精通 WebSphere MQ.pdf

    《精通WebSphere MQ》一书深入探讨了IBM WebSphere MQ这一强大的消息中间件技术,旨在为读者提供全面、深入的理解和实践经验。以下是基于该书标题、描述、标签以及部分内容提炼的关键知识点: ### 1. 消息中间件...

    Java监控WebSphere MQ 7.5中间件信息

    Java监控WebSphere MQ 7.5中间件信息主要涉及到的是如何使用Java编程语言与IBM的WebSphere MQ消息中间件进行交互,以便收集、分析和管理MQ的运行时信息。WebSphere MQ,以前被称为MQSeries,是IBM提供的一种企业级的...

    Java下操作IBM Websphere MQ的项目案例

    3. **创建MQQueueManager**:这是与IBM MQ交互的第一步,通过调用`MQQueueManager`类的构造函数,传入队列管理器的名称和连接参数。 4. **打开MQQueue**:获取特定的队列对象,用于发送或接收消息。你可以使用`...

    WebSphere MQ - Messages.pdf

    根据提供的文档信息,本文将对《WebSphere MQ - Messages.pdf》这一资料进行深入解析,并从中提炼出相关的IT知识点。此文档主要围绕WebSphere MQ的消息处理技术展开,详细介绍了消息查找、阅读方法以及不同系列下的...

Global site tag (gtag.js) - Google Analytics