IBM MQ 学习,简单配置实例

创建队列管理器

[mqm@fxs-test-02 ~]$ crtmqm -q A
There are 73 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager created.
Creating or replacing default objects for A.
Default objects statistics : 40 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.

启动队列管理器A


[mqm@fxs-test-02 ~]$ strmqm A
There are 73 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager 'A' starting.
5 log records accessed on queue manager 'A' during the log replay phase.
Log replay for queue manager 'A' complete.
Transaction manager state recovered for queue manager 'A'.
WebSphere MQ queue manager 'A' started.

[mqm@fxs-test-02 ~]$ runmqsc A
5724-H72 (C) Copyright IBM Corp. 1994, 2005.    ALL RIGHTS RESERVED.
Starting MQSC for queue manager A.

创建死信队列

define QL(NT.DEADQ) DEFPSIST(YES) REPLACE
       4 : define QL(NT.DEADQ) DEFPSIST(YES) REPLACE
AMQ8006: WebSphere MQ queue created.


更改队列管理器属性,设置其死信队列

ALTER QMGR DEADQ(NT.DEADQ)
       5 : ALTER QMGR DEADQ(NT.DEADQ)
AMQ8005: WebSphere MQ queue manager changed.

创建进程定义

6 : DEFINE PROCESS(PRO) APPLTYPE(UNIX) APPLICID('runmqchl -c chl -mA')
AMQ8010: WebSphere MQ process created.

创建本地传输队列

8 : DEFINE QL(LSQ) USAGE(XMITQ) DEFPSIST(YES) INITQ(SYSTEM.CHANNEL.INITQ) PROCESS(PRO) REPLACE
AMQ8006: WebSphere MQ queue created.

创建远程队列定义,对应于UNIX机器上的本地队列RLSQ,传输队列为LSQ


9 : DEFINE QREMOTE(RSQ) RNAME(RLSQ) RQMNAME(B) XMITQ(LSQ)
AMQ8006: WebSphere MQ queue created.

创建发送方通道,其传输队列为LSQ,远程主机地址为10.4.5.213,侦听端口为2424

10 : DEFINE CHANNEL(SDR) CHLTYPE(SDR) CONNAME('10.4.5.213(2424)') XMITQ(LSQ) REPLACE
AMQ8014: WebSphere MQ channel created.

创建服务器连接通道

11 : DEFINE CHANNEL(S_A) CHLTYPE(SVRCONN) REPLACE

AMQ8014: WebSphere MQ channel created.

 

在10.4.5.213上


[mqm@fxstest ~]$ crtmqm -q B
There are 75 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager created.
Creating or replacing default objects for B.
Default objects statistics : 40 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.


启动队列管理器

[mqm@fxstest ~]$ strmqm B
There are 75 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager 'B' starting.
5 log records accessed on queue manager 'B' during the log replay phase.
Log replay for queue manager 'B' complete.
Transaction manager state recovered for queue manager 'B'.
WebSphere MQ queue manager 'B' started.


运行MQ控制台命令


[mqm@fxstest ~]$ runmqsc B
5724-H72 (C) Copyright IBM Corp. 1994, 2005.    ALL RIGHTS RESERVED.
Starting MQSC for queue manager B.

创建死信队列

DEFINE QL(UNIX.DEADQ) DEFPSIST(YES) REPLACE
       1 : DEFINE QL(UNIX.DEADQ) DEFPSIST(YES) REPLACE
AMQ8006: WebSphere MQ queue created.


更改队列管理器属性,设置其死信队列


ALTER QMGR DEADQ(UNIX.DEADQ)
       2 : ALTER QMGR DEADQ(UNIX.DEADQ)
AMQ8005: WebSphere MQ queue manager changed.


创建接收方通道,其名字必须与远程发送方相同

    3 : DEFINE CHANNEL(SDR) CHLTYPE(RCVR) REPLACE
AMQ8014: WebSphere MQ channel created.

 创建本地队列
  
    4 : DEFINE QL(RLSQ) DEFPSIST(YES) REPLACE
AMQ8006: WebSphere MQ queue created.


 创建服务器连接通道

6 : DEFINE CHANNEL(S_UNIX) CHLTYPE(SVRCONN) REPLACE
AMQ8014: WebSphere MQ channel created.


在10.4.5.233上:


[mqm@fxs-test-02 ~]$ runmqchl -c SDR -m A
5724-H72 (C) Copyright IBM Corp. 1994, 2005.    ALL RIGHTS RESERV
05/08/07 17:24:54 Channel 'SDR' is starting.
05/08/07 17:25:14 AMQ9514: Channel 'SDR' is in use.
05/08/07 17:25:14 AMQ9999: Channel program ended abnormally.
[mqm@fxs-test-02 ~]$ runmqchl -c SDR -m A
5724-H72 (C) Copyright IBM Corp. 1994, 2005.    ALL RIGHTS RESERV                                                                                                 ED.
05/08/07 17:26:12 Channel 'SDR' is starting.
05/08/07 17:26:32 AMQ9514: Channel 'SDR' is in use.
05/08/07 17:26:32 AMQ9999: Channel program ended abnormally.

[mqm@fxs-test-02 ~]$ export PATH=$PATH:/opt/mqm/samp/bin/
[mqm@fxs-test-02 ~]$ amqsput RSQ A
Sample AMQSPUT0 start
target queue is RSQ
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDDD


在10.4.5.213上:

[mqm@fxstest ~]$    export PATH=$PATH:/opt/mqm/samp/bin/
[mqm@fxstest ~]$ amqsget SDR B
Sample AMQSGET0 start
MQOPEN ended with reason code 2085
unable to open queue for input
Sample AMQSGET0 end
[mqm@fxstest ~]$ amqsget RLSQ    B
Sample AMQSGET0 start
message <DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD>
message <DDDDDDDDDDDDDDDDDDDDD>
no more messages
Sample AMQSGET0 end
[mqm@fxstest ~]$

 

心得:
    一:在发送要起动通道:runmqchl -c SDR -m A 在接收方不用
    二:在接收方要起动端口,而在发送方不用。
    三:在接收方没有接收到消息的时侯可以看一下接收方的端口是不是处天LISTEN状态。
    四:在发送方发送了但接收方没有接收到的情况下可以看双方的错误日志文件来查明原因:/var/mqm/qmgrs/当前管理器的名字/errors/
    五: 查看所有的列队和管理器可以用:DSPMQ
   
  
在上面的基础上进行双向配置:


在10.4.5.213上

本地传输队列:

DEFINE QL(LLSQ) USAGE(XMITQ) DEFPSIST(YES) INITQ(SYSTEM.CHANNEL.INITQ) REPLACE
      1 : DEFINE QL(LLSQ) USAGE(XMITQ) DEFPSIST(YES) INITQ(SYSTEM.CHANNEL.INITQ) REPLACE
AMQ8006: WebSphere MQ queue created.

远程队列:

DEFINE QREMOTE(RRSQ) RNAME(RRLSQ) RQMNAME(A) XMITQ(LLSQ)
      2 : DEFINE QREMOTE(RRSQ) RNAME(RRLSQ) RQMNAME(A) XMITQ(LLSQ)
AMQ8006: WebSphere MQ queue created.


创建发送方通道,其传输队列为LLSQ,远程主机地址为10.4.5.233,侦听端口为2424


DEFINE CHANNEL(SSDR) CHLTYPE(SDR) CONNAME('10.4.5.233(2424)') XMITQ(LLSQ) REPLACE
      3 : DEFINE CHANNEL(SSDR) CHLTYPE(SDR) CONNAME('10.4.5.233(2424)') XMITQ(LLSQ) REPLACE
AMQ8014: WebSphere MQ channel created.


  
在10.4.5.233上


建接收方通道:


DEFINE CHANNEL(SSDR) CHLTYPE(RCVR) REPLACE
      1 : DEFINE CHANNEL(SSDR) CHLTYPE(RCVR) REPLACE
AMQ8014: WebSphere MQ channel created.

创建本地队列
  
   4 : DEFINE QL(RRLSQ) DEFPSIST(YES) REPLACE
AMQ8006: WebSphere MQ queue created.

启动端口:

[mqm@fxs-test-02 errors]$ runmqlsr -t tcp -p 2424 -m A


再开一个213的窗口

在213上发消息:


[mqm@fxstest ~]$ amqsput RRSQ   B
Sample AMQSPUT0 start
target queue is RRSQ
DDDDDDDDDDDDDDD
FFFFFFFFFFFFFFF
DDDDDDDDDDDDDDD
FFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFF

 

再开一个窗口233的

在233上接消息:


[mqm@fxs-test-02 errors]$ amqsget RRLSQ A
Sample AMQSGET0 start
message <FFFFFFFFFFFFFFF>
message <DDDDDDDDDDDDDDD>
message <FFFFFFFFFFFFFFFFF>
message <FFFFFFFFFFFFFFFFFFFFFFF>
no more messages
Sample AMQSGET0 end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值