Defining the MQ objects (channels and queues) for each queue manager is very straightforward, the trick is making sure the user matches the names of the channels for each queue manager. To setup communication between 2 queue managers, each queue manager requires a minimum of 1 send channel, 1 transmission queue and 1 receiver channel.
The testing section of this blog requires that the MQ samples be installed.
In this example, the following queue managers are used:
– MQA1 is a queue manager residing on a AIX server
– MQL1 is a queue manager residing on a Linux server
In this example, the following hostnames are used:
– aix_server is the hostname of the AIX server
– linux_server is the hostname of the Linux server
Defining the channels and queues for each queue manager
Step #1: On the AIX server, create a file called mqa1_aix.mqsc and copy the following MQSC commands into the file:
* * MQSC commands for queue manager: MQA1 * * Define a local queue for testing: DEFINE QLOCAL(TEST.AIX.QL) REPLACE * Define a remote queue for testing: DEFINE QREMOTE(TEST.LINUX.QR) + RNAME(TEST.LINUX.QL) + RQMNAME(MQL1) + XMITQ(MQL1) + REPLACE * Define a transmission queue for the sender channel: DEFINE QLOCAL(MQL1) + USAGE(XMITQ) + TRIGGER + TRIGTYPE(FIRST) + TRIGDATA(' ') + PROCESS(' ') + INITQ('SYSTEM.CHANNEL.INITQ') + REPLACE * Define a sender channel: DEFINE CHANNEL(MQA1.MQL1) + CHLTYPE(SDR) + TRPTYPE(TCP) + CONNAME('linux_server(1414)') + XMITQ(MQL1) + REPLACE * Define a receiver channel: DEFINE CHANNEL(MQL1.MQA1) + CHLTYPE(RCVR) + TRPTYPE(TCP) + REPLACE * *** End of commands ***
Step #2: On the AIX server, run the runmqsc to process the MQSC commands contained in the MQSC file:
runqmsc MQA1 < mqa1_aix.mqsc > mqa1_aix.mqsc.out
Check the bottom of the mqa1_aix.mqsc.out file for any errors.
Step #3: On the Linux server, create a file called mql1_linux.mqsc and copy the following MQSC commands into the file:
* * MQSC commands for queue manager: MQL1 * * Define a local queue for testing: DEFINE QLOCAL(TEST.LINUX.QL) REPLACE * Define a remote queue for testing: DEFINE QREMOTE(TEST.AIX.QR) + RNAME(TEST.AIX.QL) + RQMNAME(MQA1) + XMITQ(MQA1) + REPLACE * Define a transmission queue for the sender channel: DEFINE QLOCAL(MQA1) + USAGE(XMITQ) + TRIGGER + TRIGTYPE(FIRST) + TRIGDATA(' ') + PROCESS(' ') + INITQ('SYSTEM.CHANNEL.INITQ') + REPLACE * Define a sender channel: DEFINE CHANNEL(MQL1.MQA1) + CHLTYPE(SDR) + TRPTYPE(TCP) + CONNAME('aix_server(1414)') + XMITQ(MQA1) + REPLACE * Define a receiver channel: DEFINE CHANNEL(MQA1.MQL1) + CHLTYPE(RCVR) + TRPTYPE(TCP) + REPLACE * *** End of commands ***
Step #4: On the Linux server, run the runmqsc to process the MQSC commands contained in the MQSC file:
runqmsc MQL1 < mql1_linux.mqsc > mql1_linux.mqsc.out
Check the bottom of the mql1_linux.mqsc.out file for any errors.
Step #5: On the AIX server, run the following runmqsc command:
echo 'START CHANNEL(MQA1.MQL1)' | runqmsc MQA1
Make sure the the channel successfully starts.
Step #6: On the Linux server, run the following runmqsc command:
echo 'START CHANNEL(MQL1.MQA1)' | runqmsc MQL1
Make sure the the channel successfully starts.
Testing the setup
Step #7: Sending a message from queue manager MQA1 to queue manager MQL1. On the AIX server, run the following command (press Enter on a blank line to terminate amqsput):
/opt/mqm/samp/bin/amqsput TEST.LINUX.QR MQA1 this is a test message <Enter> <Enter>
Step #8: On the Linux server, run the following amqsget to retrieve the message:
/opt/mqm/samp/bin/amqsget TEST.LINUX.QL MQL1
Did amqsget output the “test message” ?
Step #9: Sending a message from queue manager MQL1 to queue manager MQA1. On the Linux server, run the following command (press Enter on a blank line to terminate amqsput):
/opt/mqm/samp/bin/amqsput TEST.AIX.QR MQL1 this is a test message #2 <Enter> <Enter>
Step #10: On the AIX server, run the following amqsget to retrieve the message:
/opt/mqm/samp/bin/amqsget TEST.AIX.QL MQA1
Did amqsget output the “test message” ?
If you have successfully completed the above 10 steps, then you have setup communication between 2 queue managers.
Regards,
Roger Lacroix
Capitalware Inc.