Publish/subscribe hierarchy scenario 1: Using point-to-point channels with queue manager name alias
This is the first in a set of three scenarios that set up a publish/subscribe hierarchy in different ways to establish the connection between queue managers. This scenario sets up a publish/subscribe hierarchy that uses point-to-point channels with queue manager name alias.
About this task
This set of scenarios all use a parent queue manager called QM1, and two child queue managers called QM2, and QM3.
Scenario 1 is split into smaller sections to make the process easier to follow.
Procedure
- Create the queue managers.
- Create and start three queue managers called QM1, QM2, and QM3 using the following commands:
crtmqm -u SYSTEM.DEAD.LETTER.QUEUE QM1 strmqm QM1 crtmqm -u SYSTEM.DEAD.LETTER.QUEUE QM2 strmqm QM2 crtmqm -u SYSTEM.DEAD.LETTER.QUEUE QM3 strmqm QM3- Enable the queue manager publish/subscribe mode by using the following command on all three queue managers:
ALTER QMGR PSMODE(ENABLED)
- Establish point-to-point channel connections between queue managers using a queue manager alias with the same name as the parent queue manager.
- Define a transmission queue and queue manager alias on QM2 to QM1. Define a sender channel to QM1 and a receiver channel for the sender channel created on QM1 for QM2:
DEFINE QLOCAL(QM1.XMITQ) USAGE(XMITQ) DEFINE QREMOTE (QM1) RNAME('') RQMNAME(QM1) XMITQ(QM1.XMITQ) DEFINE CHANNEL('QM2.TO.QM1') CHLTYPE(SDR) CONNAME('localhost(9999)') XMITQ(QM1.XMITQ) TRPTYPE(TCP) DEFINE CHANNEL('QM1.TO.QM2') CHLTYPE(RCVR) TRPTYPE(TCP)- Define a transmission queue and queue manager alias on QM3 to QM1. Define sender channel to QM1 and a receiver channel for the sender channel created on QM1 for QM3:
DEFINE QLOCAL(QM1.XMITQ) USAGE(XMITQ) DEFINE QREMOTE (QM1) RNAME('') RQMNAME(QM1) XMITQ(QM1.XMITQ) DEFINE CHANNEL('QM3.TO.QM1') CHLTYPE(SDR) CONNAME('localhost(9999)') XMITQ(QM1.XMITQ) TRPTYPE(TCP) DEFINE CHANNEL('QM1.TO.QM3') CHLTYPE(RCVR) TRPTYPE(TCP)- Define a transmission queue and queue manager alias on QM1 to QM2 and QM3. Define sender channel to QM2 and QM3, and a receiver channel for the sender channels created on QM2 and QM3 for QM1:
DEFINE QLOCAL(QM2.XMITQ) USAGE(XMITQ) DEFINE QREMOTE (QM2) RNAME('') RQMNAME(QM2) XMITQ(QM2.XMITQ) DEFINE CHANNEL('QM1.TO.QM2') CHLTYPE(SDR) CONNAME('localhost(7777)') XMITQ(QM2.XMITQ) TRPTYPE(TCP) DEFINE CHANNEL('QM2.TO.QM1') CHLTYPE(RCVR) TRPTYPE(TCP) DEFINE QLOCAL(QM3.XMITQ) USAGE(XMITQ) DEFINE QREMOTE (QM3) RNAME('') RQMNAME(QM3) XMITQ(QM3.XMITQ) DEFINE CHANNEL('QM1.TO.QM3') CHLTYPE(SDR) CONNAME('localhost(8888)') XMITQ(QM3.XMITQ) TRPTYPE(TCP) DEFINE CHANNEL('QM3.TO.QM1') CHLTYPE(RCVR) TRPTYPE(TCP)- Start the appropriate listeners on the queue managers:
runmqlsr -m QM1 -t TCP -p 9999 & runmqlsr -m QM2 -t TCP -p 7777 & runmqlsr -m QM3 -t TCP -p 8888 &- Start the following channels:
- On QM1:
START CHANNEL('QM1.TO.QM2') START CHANNEL('QM1.TO.QM3')- On QM2:
START CHANNEL('QM2.TO.QM1')- On QM3:
START CHANNEL('QM3.TO.QM1')
- Check that all the channels have started:
DISPLAY CHSTATUS('QM1.TO.QM2') DISPLAY CHSTATUS('QM1.TO.QM3') DISPLAY CHSTATUS('QM2.TO.QM1') DISPLAY CHSTATUS('QM3.TO.QM1')
- Connect the queue managers and define a topic. Connect the child queue managers QM2 and QM3 to the parent queue manager QM1.
- On QM2 and QM3, set the parent queue manager to QM1:
ALTER QMGR PARENT (QM1)- Run the following command on all queue managers to check that the child queue managers are connected to the parent queue manager:
DISPLAY PUBSUB TYPE(ALL)Command output is displayed. For example, here is output for QM1, with the key details highlighted:
DISPLAY PUBSUB ALL 1 : DISPLAY PUBSUB ALL AMQ8723: Display pub/sub status details. QMNAME(QM1) TYPE(LOCAL) STATUS(ACTIVE) SUBCOUNT(6) TPCOUNT(9) AMQ8723: Display pub/sub status details. QMNAME(QM2) TYPE(CHILD) STATUS(ACTIVE) SUBCOUNT(NONE) TPCOUNT(NONE) AMQ8723: Display pub/sub status details. QMNAME(QM3) TYPE(CHILD) STATUS(ACTIVE) SUBCOUNT(NONE) TPCOUNT(NONE)- Use the amqspub.exe and amqssub.exe applications to publish and subscribe the topic.
- Run this command in the first command window:
amqspub Sport/Soccer QM2- Run this command in the second command window:
amqssub Sport/Soccer QM1- Run this command in the third command window:
amqssub Sport/Soccer QM3
Results
The amqssub.exe applications in the second and third command windows receive the messages published in the first command window.
Parent topic: Publish/subscribe hierarchy scenarios