SERVER TO SERVER COMMUNICATION
Setup of Sender Workstation
- Create a default queue manager called QMSENDER. At a command prompt in a window, enter the following command:
crtmqm -q QMSENDER
The -q option specifies that this queue manager is the default queue manager.
Messages tell you that the queue manager is created, and that the default WebSphere® MQ objects are created.
- Start the default queue manager. Enter the following command:
strmqm QMSENDER
A message tells you when the queue manager starts.
- Enable MQSC commands. Enter the following command:
runmqsc
The message Starting WebSphere MQ Commands is displayed when MQSC has started. MQSC has no command prompt.
- In the MQSC command window, define a local queue to use as a transmission queue called QMA. Enter the following command:
define qlocal(TRANSMITQSENDER) usage(xmitq)
The message WebSphere MQ queue created is displayed when the queue is created.
- In the MQSC command window, create a local definition of the remote queue. Enter the following command:
define qremote(LOCAL.DEF.OF.REMOTE.QUEUE) rname(SAMPLE.QUEUE) rqmname('QMRECEIVER') xmitq(TRANSMITQSENDER)
The rname parameter specifies the name of the queue on the remote machine to which the message will be sent. Therefore, the name that the rname parameter specifies must be the name of the queue to which you want to send the message (that is, sample.queue on the receiver workstation). rqmname is the queue manager name on the remote machine.
define channel(QMSENDER.QMRECEIVER) chltype(sdr) conname("con-name(port)") xmitq(TRANSMITQSENDER) trptype(tcp)
Where:
con-name is the TCP/IP address of the receiver workstation.
port is the port on which the listener will be running on the receiver machine, the default value is 1414.
- In the MQSC command window, stop MQSC. Stop MQSC. Enter the Command: end
You have now defined the following objects:
- A default queue manager called QMSENDER
- A transmission queue called TRANSMITQSENDER
- A remote queue called LOCAL.DEF.OF.REMOTE.QUEUE
- A sender channel called QMSENDER.QMRECEIVER
Setup of Receiver Workstation
- Create a default queue manager called QMRECEIVER. At the command prompt, enter the following command:
crtmqm -q QMRECEIVER
Messages tell you that the queue manager is created, and that the default WebSphere® MQ objects are created.
- Start the queue manager. Enter the following command:
strmqm
A message tells you when the queue manager starts.
- Open a new command prompt window and enable MQSC commands. Enter the following command:
runmqsc
The message Starting WebSphere MQ Commands is displayed when MQSC starts. MQSC has no command prompt.
- In the MQSC window, define a local queue called SAMPLE.QUEUE. Enter the following command:
define qlocal(SAMPLE.QUEUE)
The message WebSphere MQ queue created is displayed when the queue is created.
- In the MQSC window, create a receiver channel. Enter the following command:
define channel(QMSENDER.QMRECEIVER) chltype(rcvr) trptype(tcp)
- In the MQSC window, start the default WebSphere MQ listener by entering the following command:
start listener(SYSTEM.DEFAULT.LISTENER.TCP)
- In the MQSC window, verify the listener process has started by executing the command:
display lsstatus(SYSTEM.DEFAULT.LISTENER.TCP)
- In the MQSC window, stop MQSC. Enter the following command:
end
You have now defined the following objects:
· A default queue manager called QMRECEIVER
· A queue called SAMPLE.QUEUE
· A receiver channel called QMSENDER.QMRECEIVER
Starting Channel
- If the queue managers on the two workstations have stopped for any reason, restart them now using the strmqm command.
- On the sender workstation, enable MQSC commands. Enter the following:
runmqsc
- Using the MQSC window, start the sender channel. Enter the following command:
start channel(QMSENDER.QMRECEIVER)
The receiver channel on the receiver workstation is started automatically when the sender channel starts.
- Using the MQSC window, stop MQSC. Enter the following command:
end
Testing Communication between the Workstations
- On the sender workstation, in a new command window, put a message on the queue by entering the following command from /opt/mqm/samp/bin directory
amqsput LOCAL.DEF.OF.REMOTE.QUEUE
This puts the message to the local definition of the remote queue, which in turn specifies the name of the remote queue.
- Type the text message, then press Enter twice.
- On the receiver workstation, get the message from the queue by entering the following command from /opt/mqm/samp/bin directory
amqsget SAMPLE.QUEUE
The sample program starts, and your message is displayed. After a short pause, the sample ends and the command prompt is displayed again.
Thus it proves the server to server communication by sending one message from the remote queue on the sender workstation to the local queue on the receiver workstation using XMITQ, Sender/Receiver Channels and Listener.