一. 創(chuàng)建隊列管理器
- 通過以下命令夜畴,創(chuàng)建名為QMGR_XXBANK的隊列管理器
crtmqm QMGR_01_BANK
- 通過輸入以下命令來啟動此隊列管理器
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.
$
二. 創(chuàng)建本地隊列
- 通過輸入以下命令來啟用 MQSC 命令
runmqsc QMGR_01_BANK
- 創(chuàng)建本隊隊列
define qlocal (Q1)
此時會顯示消息贪绘,告訴您已經(jīng)創(chuàng)建了隊列和缺省 IBM MQ 對象税灌。
- 通過輸入以下命令來停止 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 將測試消息放入隊列
- 啟動 amqsput 樣本程序
在 Linux 上菱涤,更改為 MQ_INSTALLATION_PATH/samp/bin 目錄,其中 MQ_INSTALLATION_PATH 表示安裝了 IBM MQ 的高級目錄洛勉。輸入以下命令:
./amqsput Q1 QMGR_01_BANK
- 在一行或多行上輸入某些消息文本粘秆,然后按 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
$
四收毫、 驗證是否已發(fā)送測試消息
- 啟動 amqsget 樣本程序
在 Linux 上攻走,更改為 MQ_INSTALLATION_PATH/samp/bin 目錄殷勘,其中 MQ_INSTALLATION_PATH 表示安裝了 IBM MQ 的高級目錄。輸入以下命令:
./amqsget Q1 QMGR_01_BANK
結(jié)果
此時會啟動該樣本程序昔搂,并顯示您的消息以及此隊列上的任何其他消息玲销。在暫停 15 秒鐘后,樣本程序結(jié)束摘符,并再次顯示命令提示符贤斜。
示例如下:
$ 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
$
參考:
將消息發(fā)送至本地隊列