美文网首页
IBM MQ简明教程——1. 将消息发送至本地队列

IBM MQ简明教程——1. 将消息发送至本地队列

作者: 改变_从现在开始 | 来源:发表于2019-04-12 15:10 被阅读0次

一. 创建队列管理器

  1. 通过以下命令,创建名为QMGR_XXBANK的队列管理器
crtmqm QMGR_01_BANK
  1. 通过输入以下命令来启动此队列管理器
strmqm QMGR_01_BANK

示例如下:

$ crtmqm QMGR_01_BANK
IBM MQ queue manager created.
Directory '/var/mqm/qmgrs/QMGR_01_BANK' created.
The queue manager is associated with installation 'Installation1'.
Creating or replacing default objects for queue manager 'QMGR_01_BANK'.
Default objects statistics : 83 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.
$ strmqm QMGR_01_BANK
The system resource RLIMIT_NOFILE is set at an unusually low level for IBM MQ.
IBM MQ queue manager 'QMGR_01_BANK' starting.
The queue manager is associated with installation 'Installation1'.
5 log records accessed on queue manager 'QMGR_01_BANK' during the log replay phase.
Log replay for queue manager 'QMGR_01_BANK' complete.
Transaction manager state recovered for queue manager 'QMGR_01_BANK'.
IBM MQ queue manager 'QMGR_01_BANK' started using V9.1.1.0.
$

二. 创建本地队列

  1. 通过输入以下命令来启用 MQSC 命令
runmqsc QMGR_01_BANK
  1. 创建本队队列
define qlocal (Q1)

此时会显示消息,告诉您已经创建了队列和缺省 IBM MQ 对象。

  1. 通过输入以下命令来停止 MQSC
end

示例如下:

$ runmqsc QMGR_01_BANK
5724-H72 (C) Copyright IBM Corp. 1994, 2018.
Starting MQSC for queue manager QMGR_01_BANK.


define qlocal (Q1)
     1 : define qlocal (Q1)
AMQ8006I: IBM MQ queue created.
end
     2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
$

三、 使用 amqsput 将测试消息放入队列

  1. 启动 amqsput 样本程序
    在 Linux 上,更改为 MQ_INSTALLATION_PATH/samp/bin 目录,其中 MQ_INSTALLATION_PATH 表示安装了 IBM MQ 的高级目录。输入以下命令:
./amqsput Q1 QMGR_01_BANK
  1. 在一行或多行上输入某些消息文本,然后按 Enter 键两次。 此时会显示以下消息:
    Sample AMQSPUT0 end
    示例如下:
$ pwd
/opt/mqm/samp/bin
$ ./amqsput Q1 QMGR_01_BANK
Sample AMQSPUT0 start
target queue is Q1
Hello World!
How are you?
fine, thank you.

Sample AMQSPUT0 end
$

四、 验证是否已发送测试消息

  1. 启动 amqsget 样本程序
    在 Linux 上,更改为 MQ_INSTALLATION_PATH/samp/bin 目录,其中 MQ_INSTALLATION_PATH 表示安装了 IBM MQ 的高级目录。输入以下命令:
./amqsget Q1 QMGR_01_BANK

结果
此时会启动该样本程序,并显示您的消息以及此队列上的任何其他消息。在暂停 15 秒钟后,样本程序结束,并再次显示命令提示符。
示例如下:

$ pwd
/opt/mqm/samp/bin
$ ./amqsget Q1 QMGR_01_BANK
Sample AMQSGET0 start
message <Hello World!>
message <How are you?>
message <fine, thank you.>
no more messages
Sample AMQSGET0 end
$

参考:
将消息发送至本地队列

相关文章

网友评论

      本文标题:IBM MQ简明教程——1. 将消息发送至本地队列

      本文链接:https://www.haomeiwen.com/subject/xmnqwqtx.html