Date Created: Thu 14-Feb-2008

Related Document Categories:

Get my WebSphere MQ course here >> http://www.themiddlewareshop.com/products/


Tutorial on how to configure a remote queue definition to demonstrate MQ intercommunication.

In this example I am going to briefly demonstrate MQ intercommunication. What I mean by intercommunication is allowing a message to be put on a local queue on a local queue manager and to have that message sent to a remote queue on a remote queue manager.

If you need to learn how to install WebSphere MQ then read my article which covers how to install MQ on Linux using Fedora.

For intercommunication to occur you need to create MQ channels. Channel objects provide a means for local queues to talk to connect to remote queues. You could say that channel object come in pairs. One sender and one receiver i.e that is two ends of a channel must exist.Messages flow one-way in a channel. If you wish two queue managers remote to each other to communicate then you must have a local queue and remote queue definition with a channel set-up for each direction. This means you needs one channel for sending left to right and a different channel for sending from right to left. In other words for a sender to receive and receiver to send you must define two serrate channels.

In intercommunication we also need listeners created and running with TCP / Port settings set accordingly for each end of the channel.

I am going to create two queue managers, one called qm.apple which will be my receiving queue and another called qm.orange which will be the sending queue manager.

First we are going to create our first queue manager. First install WebSphere MQ. I am currently using WebSphere MQ version 6 on Linux.
By using the command crtmqm without the -q switch the queue is not the default queue.

crtmqm qm.apple

WebSphere MQ queue manager created.
Creating or replacing default objects for qm.apple.
Default objects statistics : 40 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.

If we run the command strmqm we get: AMQ8118: WebSphere MQ queue manager does not exist. This is due tot the fact we have no default queue manager. Now we are going to create the sending queue manager qm.orange.

crtmqm -q qm.orange

WebSphere MQ queue manager created.
Creating or replacing default objects for qm.orange.
Default objects statistics : 40 created. 0 replaced. 0 failed.
Completing setup.

strmqm
WebSphere MQ queue manager 'qm.orange' starting.
5 log records accessed on queue manager 'qm.orange' during the log replay phase.
Log replay for queue manager 'qm.orange' complete.
Transaction manager state recovered for queue manager 'qm.orange'.
WebSphere MQ queue manager 'qm.orange' started.

You can see that since I used the -q switch the qm.orange queue manager is now the default queue manager and when I issue the strmqm command it is able to start the default queue manager. To start qm.apple I type strmqm qm.apple

strmqm qm.apple
WebSphere MQ queue manager 'qm.apple' starting.
5 log records accessed on queue manager 'qm.apple' during the log replay phase.
Log replay for queue manager 'qm.apple' complete.
Transaction manager state recovered for queue manager 'qm.apple'.
WebSphere MQ queue manager 'qm.apple' started.

We now have two queue managers. What we want to do now is create a queue to receive messages on qm.apple. Do do this we use the command line utility called MQSC. The command is runmqsc. It is a command line interpreter which executes MQ confirmation command to adjust MQ object settings. if we type runmqsc we will automatically start the MQSC tool for the default queue manager.

runmqsc qm.apple

runmqsc qm.apple
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.apple.


define qlocal(q1)
1 : define qlocal(q1)
AMQ8006: WebSphere MQ queue created.
end
2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.

What we need to do now is create a listener for the qm.apple which allows our sending queue manager (qm.orange) to connect via channel. We are going to make the listener use port 30000. If you follow the link above which explains a listener you can learn what the default port is.

runmqsc qm.apple
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.orange.


define listener(qm.apple.listener) trptype(TCP) port(30000)
1 : define listener(qm.apple.listener) trptype(TCP) port(30000)
AMQ8626: WebSphere MQ listener created.
start listener(qm.apple.listener)
2 : start listener(qm.apple.listener)
AMQ8021: Request to start WebSphere MQ Listener accepted.
end
3 : end
2 MQSC commands read.
No commands have a syntax error.
All valid MQSC commands were processed.

What we are going to do now is create a listener for qm.orange. You may think, why do we need a listener for qm.orange when it is the sending queue manager? Well it is because to use MQ Explorer form a remote machine i.e. my windows machine to administer MA on my Linux box I will need to connect as a client to the queue managers via their listeners.

runmqsc qm.orange
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.orange.


define listener(qm.orange.listener) trptype(TCP) port(30001) ipaddr(192.168.0.60)
1 : define listener(qm.orange.listener) trptype(TCP) port(30001) ipaddr(192.168.0.60)
AMQ8626: WebSphere MQ listener created.
start listener(qm.orange.listener)
2 : start listener(qm.orange.listener)
AMQ8021: Request to start WebSphere MQ Listener accepted.
end
3 : end
2 MQSC commands read.
No commands have a syntax error.
All valid MQSC commands were processed.

You will notice in this listener I added the ipaddr parameter this is to show that you can see what ipaddress you wish to listen on. This is key for intercommunication. Remember firewalls will need to be configures if you have them to allow communication on these ports.

If we look at the running listener proceses.

ps -ef | grep runmqlsr
mqm 17609 17471 0 08:50 ? 00:00:00 /opt/mqm/bin/runmqlsr -r -m qm.orange -t TCP -p 30001 -i 192.168.0.60
mqm 17636 17526 0 08:56 ? 00:00:00 /opt/mqm/bin/runmqlsr -r -m qm.apple -t TCP -p 30000

You can see that MQ is running the command runmqlsr and the qm.apple listern is not bound to a specific ipaddress. What we will do not is alter the qm.apple listener.


runmqsc qm.apple
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.apple.


alter listener(qm.apple.listener) ipaddr(192.168.0.60)
1 : alter listener(qm.apple.listener) ipaddr(192.168.0.60)
AMQ8405: Syntax error detected at or near end of command segment below:-
alter listener(qm.apple.listener) ipaddr

AMQ8427: Valid syntax for the MQSC command:

ALTER LISTENER(listener_name)
TRPTYPE( TCP | SPX | NETBIOS | LU62 )
alter listener(qm.apple.listener) trptype(tcp) ipaddr(192.168.0.60)
2 : alter listener(qm.apple.listener) trptype(tcp) ipaddr(192.168.0.60)
AMQ8623: WebSphere MQ listener changed.
end
3 : end
2 MQSC commands read.
One command has a syntax error.
All valid MQSC commands were processed.

As you can see a typing mistake and so MQSC will prompt with an error to show some information to lead you in the right direction. Note that it doesn't always tell you all the command options in complete detail, this is something you will have to read in help documentation.

We will have to bounce the listener for the ipaddress parameter to take effect.

runmqsc qm.apple
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.apple.

stop listener(qm.apple.listener)
1 : stop listener(qm.apple.listener)
AMQ8706: Request to stop WebSphere MQ Listener accepted.
start listener(qm.apple.listener)
2 : start listener(qm.apple.listener)
AMQ8021: Request to start WebSphere MQ Listener accepted.
end
3 : end
2 MQSC commands read.
No commands have a syntax error.
All valid MQSC commands were processed.

OK we now have to running queue managers with appropriate listeners. What we need to do now is create a transmission queue on qm.orange. We require a transmission queue to be able to talk to a channel object. We use a channel to allow qm.orange to talk to qm.apple. We will also need to create a remote queue definition which will represent our remote queue q1 on qm.apple which we want to send messages to.

runmqsc qm.orange
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.orange.


define qlocal (qm.orange.tq) usage(xmitq)
1 : define qlocal (qm.orange.tq) usage(xmitq)
AMQ8006: WebSphere MQ queue created.
end
2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.


runmqsc
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.orange.


define qremote(q1) rname(q1) rqmname(qm.apple) xmitq(qm.orange.tq)
1 : define qremote(q1) rname(q1) rqmname(qm.apple) xmitq(qm.orange.tq)
AMQ8006: WebSphere MQ queue created.
end
2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.

We have created the transmission queue and and a remote queue definition, we still need to create the channel object, but before we do lets use MQ explorer to see what we have created.

Before we can actually look at the queue managers we need to ensue that MQ explorer can connect to the queue managers, to do this we need to ensure that both queue managers have special channel created called SYSTEM.ADMIN.SVRCONN.

The server-connection channel, called SYSTEM.ADMIN.SVRCONN, must exist on every remote queue manager you need to manage using MQ explorer i.e. remote to the machine where you are running MQ Explorer. This channel is mandatory for every remote queue manager being administered by WebSphere MQ Explorer. Without it, remote administration is not possible.

runmqsc qm.apple
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.apple.


DEFINE CHANNEL(SYSTEM.ADMIN.SVRCONN) CHLTYPE(SVRCONN)
1 : DEFINE CHANNEL(SYSTEM.ADMIN.SVRCONN) CHLTYPE(SVRCONN)
AMQ8014: WebSphere MQ channel created.
start channel(SYSTEM.ADMIN.SVRCONN)
2 : start channel(SYSTEM.ADMIN.SVRCONN)
AMQ8018: Start WebSphere MQ channel accepted.
end
3 : end
2 MQSC commands read.
No commands have a syntax error.
All valid MQSC commands were processed.

Do the same for qm.orange. We can now connect to the queue managers. Run MQ Explorer. Remember in my example MQ explorer is running on my windows laptop where MQ is running on my remote Linux machine.




connect to qm.apple
















Connect to qm.orange












We can see the local queue called q1 on the receiving queue manager (qm.apple)



On the qm.orange queue manager we can see the transmission queue called qm.orange.tq and the remote queue definition q1. This should visualise what we have been doing in the steps above.






We can also look at the listeners







Now we wil look at the queue in detail:

This is the q1 queue on the receiving queue manager, you can see it has a default usage of normal.




What we are going to do now is create a channel objects to allow the queue managers to talk to each other. We will need a channel object at each end of the channel one will be a sender object and one will be a receiver object.

runmqsc qm.orange
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.orange.


define channel (qm.orange.qm.apple) chltype (sdr) conname ('192.168.0.60(30000)') xmitq (qm.orange.tq) trptype (tcp)
1 : define channel (qm.orange.qm.apple) chltype (sdr) conname ('192.168.0.60(30000)') xmitq (qm.orange.tq) trptype (tcp)
AMQ8014: WebSphere MQ channel created.
end
2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.


We can look in MQ explorer cand see our newly created sending channel object called qm.orange.qm.apple on qm.orange




What we need to do now is create a receiving channel object on qm.apple

runmqsc qm.apple
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.apple.


define channel (qm.orange.qm.apple) chltype (RCVR) trptype (TCP)
1 : define channel (qm.orange.qm.apple) chltype (RCVR) trptype (TCP)
AMQ8014: WebSphere MQ channel created.
end
2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.

We see ee this in MQ Explorer as shown below:




The idea is simple. MQ must always use a local queue to put a message. So we put a message on the remote queue definition and it transfers to the channel via the local transmission queue.

Lets look at the qm.orange queues to see our actual queue settings.

Transmission queue:






Remote Queue Definition:



What we can do now is start the channel. We can use MQ Explorer as shown immediately below or using MQSC as shown after. Note can start the channel at an end. What I mean is that You can start or stop the channel from either queue manager.



Starting the qm.orange.qm.apple channel using MQSC

runmqsc qm.orange
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.orange.


start channel(qm.orange.qm.apple)
1 : start channel(qm.orange.qm.apple)
AMQ8018: Start WebSphere MQ channel accepted.
end
2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.

We can also look at the status of a channel suing MQSC.

runmqsc qm.orange
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager qm.orange.


display
1 : display
AMQ8405: Syntax error detected at or near end of command segment below:-
display

AMQ8426: Valid MQSC commands are:

DISPLAY AUTHINFO
DISPLAY CHANNEL
DISPLAY CHSTATUS
DISPLAY CLUSQMGR
DISPLAY PROCESS
DISPLAY NAMELIST
DISPLAY QALIAS
DISPLAY QCLUSTER
DISPLAY QLOCAL
DISPLAY QMGR
DISPLAY QMODEL
DISPLAY QREMOTE
DISPLAY QUEUE
DISPLAY QSTATUS
DISPLAY CONN
DISPLAY SERVICE
DISPLAY LISTENER
DISPLAY SVSTATUS
DISPLAY LSSTATUS
DISPLAY QMSTATUS
display chstatus(qm.orange.qm.apple)
2 : display chstatus(qm.orange.qm.apple)
AMQ8417: Display Channel Status details.
CHANNEL(QM.ORANGE.QM.APPLE) CHLTYPE(SDR)
CONNAME(192.168.0.60(30000)) CURRENT
RQMNAME(qm.apple) STATUS(RUNNING)
SUBSTATE(MQGET) XMITQ(QM.ORANGE.TQ)
end
3 : end
2 MQSC commands read.
One command has a syntax error.
All valid MQSC commands were processed.


What we want to do now is put a message on the remote queue definition and see if it arrives on the remote queue manager.

First I will use MQ explorer as it is quick to demonstrate, then I will show using the MQ sample API programs.

On qm.orange, I right mouse click the remote queue definition and put a message






Below we can see that a message went i.e we have 1 open count and 1 close count on the transmission queue.





Open input count Read-only. This is the number of applications that are currently connected to the queue to put messages on the queue. IPPROCS
Open output count Read-only. This is the number of applications that are currently connected to the queue to get messages from the queue. OPPROCS


Lets look at the receiving queue on qm.apple and see if the message has arrived?




Ok we can see that there is a message waiting on the on the qm.apple our destination queue.

Note: If you have problems with this demo, you may need to completely restart the queue managers and start the channels to ensure that all the queue manager settings are correct. This is due to the the fact that while writing this article I may have done things in a particular order and a restart of the queue managers may need to be done to refesh the configuration depending on the order in which you follow these steps.

What I am going to do is now use the amqsput sample prograqm which uses the MQ apli to put messages onto a queue. You must install the sample RPM on Linux if you wish to use amqsput. You can use <enter> to finish entering messages.

/opt/mqm/samp/bin/amqsput q1 qm.orange
Sample AMQSPUT0 start
target queue is q1
hello world

Sample AMQSPUT0 end

You get the messages we can use qmqsget. The program will end after 10 seconds.

/opt/mqm/samp/bin/amqsget q1 qm.apple
Sample AMQSGET0 start
message <Hello Mum>
message <Hello World>

no more messages
Sample AMQSGET0 end

Get my WebSphere MQ course here >> http://www.themiddlewareshop.com/products/

Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.


  • Linked In
  • Twitter
  • About Me
  • My Blog
  • Contact Me

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Other Categories