国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

WebSphere MQ傳輸環境搭建和測試

2019-11-18 15:28:37
字體:
來源:轉載
供稿:網友
    在“WebSphere MQ程序設計初探”一文中,討論了從MQ隊列治理器的本地隊列中放置和讀出消息的程序,本文主要通過兩臺機器,搭建MQ消息傳輸的環境,并編寫測試程序進行測試。
第一、預備工作
預備2臺Win2000環境(XP也可),通過以太網連通。
機器A:代碼為00000000,ip地址為:10.1.1.1
機器B:代碼為88888888,IP地址為:10.1.1.2
安裝MQ 5.3

第二、創建MQ對象
A機器上:
1、打開“WebSphere MQ資源治理器”,新建隊列治理器,名稱為QM_00000000,其余采用默認設置;
2、在QM_00000000隊列治理器中創建本地隊列,名稱為LQ_00000000;
3、創建傳輸隊列,名稱為XQ_88888888(新建時選擇“本地隊列”,將“用法”設置為“傳輸”);
4、創建遠程隊列定義,名稱為RQ_88888888,指定遠程隊列名稱為LQ_88888888,遠程隊列治理器名稱為QM_88888888,傳輸隊列名稱為XQ_88888888;
5、創建發送方通道,名稱為00000000.88888888,傳輸協議為TCP/IP,連接名稱為10.1.1.2(1414),傳輸隊列為XQ_88888888;
6、創建接受方通道,名稱為88888888.00000000,采用默認設置;
7、創建服務器連接通道,名稱為DC.SVRCONN,采用默認設置(該通道主要給后面的測試程序使用)。
B機器和A機器上的操作一樣,只是命名不同,如下:
1、打開“WebSphere MQ資源治理器”,新建隊列治理器,名稱為QM_88888888,其余采用默認設置;
2、在QM_88888888隊列治理器中創建本地隊列,名稱為LQ_88888888;
3、創建傳輸隊列,名稱為XQ_00000000(新建時選擇“本地隊列”,將“用法”設置為“傳輸”);
4、創建遠程隊列定義,名稱為RQ_00000000,指定遠程隊列名稱為LQ_00000000,遠程隊列治理器名稱為QM_00000000,傳輸隊列名稱為XQ_00000000;
5、創建發送方通道,名稱為88888888.00000000,傳輸協議為TCP/IP,連接名稱為10.1.1.1(1414),傳輸隊列為XQ_00000000;
6、創建接受方通道,名稱為00000000.88888888,采用默認設置;
7、創建服務器連接通道,名稱為DC.SVRCONN,采用默認設置。

第三、消息測試
在A、B機器上分別啟動其發送方通道,正常情況通道狀態應為“正在運行”。
通過如下測試程序進行測試,文件名為:MQTest.java,在機器A上進行運行(如在B上運行請讀者自行適當修改)。
-------------------------------------------------------------------------------------------
import java.io.IOException;
import java.util.Hashtable;

import com.ibm.mq.MQException;
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 qName = "RQ_88888888";
    
    private static MQQueueManager qMgr; 
    private static Hashtable properties = new Hashtable();

    public static void main(String args[]) {
        try {
            properties.put("hostname", "10.1.1.1");
            properties.put("port", new Integer(1414));
            properties.put("channel", "DC.SVRCONN");
            properties.put("CCSID", new Integer(1381));
            properties.put("transport","MQSeries");
            
            // Create a connection to the queue manager 
            qMgr = new MQQueueManager(qmName,properties); 
            // Set up the options on the queue we wish to open... 
            int openOptions = 16;
            // Now specify the queue that we wish to open, 
            // and the open options... 
            MQQueue remoteQ = qMgr.
accessQueue(qName, openOptions); 
            
            // Define a simple WebSphere MQ message, and write some text in UTF format.. 
            MQMessage putMessage = new MQMessage(); 
            putMessage.writeUTF("Test"); 
            // specify the message options... 
            MQPutMessageOptions pmo = new MQPutMessageOptions(); 
            // accept the defaults, same as MQPMO_DEFAULT
            // put the message on the queue 
            remoteQ.put(putMessage,pmo); 
            System.out.println("Message has been input into the Remote Queue");

            // Close the queue... 
            remoteQ.close(); 
            // Disconnect from the queue manager 
            qMgr.disconnect(); 
        }catch (MQException ex) { 
            // If an error has occurred in the above, try to identify what went wrong 
            // Was it a WebSphere MQ error? 
            System.out.println("A WebSphere MQ error occurred : Completion code " + ex.completionCode + 
          " Reason code " + ex.reasonCode); 
        }catch (IOException ex) { 
            // Was it a Java buffer space error? 
            System.out.println("An error occurred whilst writing to the message buffer: " + ex); 
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }
}
-------------------------------------------------------------------------------------------
運行程序后,請在B機器的本地隊列LQ_88888888中檢查是否有消息存在,假如有說明測試成功。
讀者可以自行編寫把消息從對方的本地隊列讀取出來的程序。
假如讀者對以上的內容有任何疑問,可以和我聯系,qianh@cntmi.com 
版權所有,嚴禁轉載

參考資料:
1、《WebSphere MQ System Administration Guide》Third edition (May 2004),SC34-6068-02
2、《WebSphere MQ Using Java》Third edition (January 2004),SC34-6066-02
附件:MQTest.java(2K) 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 建宁县| 达拉特旗| 宜君县| 娄烦县| 中方县| 凤山县| 阿鲁科尔沁旗| 会东县| 延寿县| 个旧市| 桐庐县| 鄯善县| 南靖县| 定州市| 米脂县| 江油市| 保靖县| 五大连池市| 乃东县| 酉阳| 咸宁市| 洛浦县| 封丘县| 米脂县| 千阳县| 巧家县| 乳源| 太仆寺旗| 绿春县| 界首市| 聊城市| 商水县| 正蓝旗| 麻阳| 武平县| 大理市| 黔西县| 修文县| 屏山县| 吉安县| 弋阳县|