Monday, 20 January 2014

Communication between a non - clustered QMGR with a QMGR inside Cluster


     This post contains the detailed steps to be followed to establish communication between a Queue Manager (here after called QMGR) inside cluster and a QMGR outside cluster using a gateway QMGR. I had personally spent a lot of time in getting this correct. So thought of putting it together as a post for posterity. Here I am planning to start with 2 QMGRs in Cluster and the create a 3rd QMGR and establish communication with the clustered QMGRs

1.     Create QMGRs QM1 and QM2

                   crtmqm QM1
                   crtmqm QM2

2.     Alter both QM1 and QM2 as fullrespoditory QMGRs of the Cluster QMGRS

                  ALTER QMGR REPOS(QMGRS)

3.     Create listeners QM1.LSR, and QM2.LSR on QM1 and QM2 respectively and start the listeners

 DEF LISTENER(QM1.LSR) TRPTYPE(TCP) PORT(1234)
                   DEF LISTENER(QM2.LSR) TRPTYPE(TCP) PORT(1235)

4.     Create channels between QM1 and QM2 and start the channels

 ON QM1 :

                   DEF CHANNEL(TO.QM2) CHYTYPE(CLUSSDR) CONNAME('localhost(1235)') CLUSTER(QMGRS)
                   DEF CHANNEL(TO.QM1) CHYTYPE(CLUSRCVR) CONNAME('localhost(1234)') CLUSTER(QMGRS)

                   ON QM2:

                    DEF CHANNEL(TO.QM1) CHYTYPE(CLUSSDR) CONNAME('localhost(1234)') CLUSTER(QMGRS)
                    DEF CHANNEL(TO.QM2) CHYTYPE(CLUSRCVR) CONNAME('localhost(1235)') CLUSTER(QMGRS)

5.     Now the cluster set up is ready. Let’s now try to connect a QMGR inside cluster, let’s say QM2 with a QMGR outside cluster. To achieve this, we will create a new QMGR, QM3

 crtmqm QM3

6.     Create a listener QM3.LSR in QM3 and start the listener

 DEF LISTENER(QM3.LSR) TRPTYPE(TCP) PORT(1236)

7.     As QM3 is outside the cluster, we have to use distributed queuing technique to communicate with other QMGRs. In this case, QM1 acts as a gateway to the cluster QMGRS. I this case lets first see how a message can be sent from Outside the cluster, ie, from QM3 to a queue (Q2) on QMGR QM2 inside the Cluster.

Create a sender – receiver channel pair between QM3 and QM1

 ON QM3:

                   DEF QLOCAL(QM1) USAGE(XMITQ)
                   DEF CHANNEL(TO.CLUS) CHLTYPE(SDR) CONNAME('localhost(1234)') XMITQ(QM1)

                   ON QM1 :

                   DEF CHANNEL(TO.CLUS) CHLTYPE(RCVR)

8.     Create a Remote queue Q2 on QM3

 DEF QREMOTE(Q2) RNAME(Q2) RQMNAME(QM2) XMITQ(QM1)

9.     Create a cluster local queue Q2 on QM2

DEF QLOCAL(Q2) CLUSTER(QMGRS)

The setup is complete now. Make sure that all your channels are up and running. Now, if you try to post a message in to the remote queue Q2 on QM3, you can find that it safely lands on the local queue Q2 on QM2.

10.  So that’s the Inbound case. Let’s see how a reply from QM2 QMGR (which is inside cluster ) can fly back to QM3 QMGR (which is outside cluster). Here we have to use the concept of Queue Manager Alias. Here I am going to define a queue manager alias on QM1 (which is the gateway) and publish this info to the cluster.

 DEF QREMOTE(QM3.ALIAS) RNAME('') RQMNAME(QM3) XMITQ(QM3)

11. Create a sender – receiver channel pair from QM1 to QM3

                   ON QM1 :

                   DEF QLOCAL(QM3) USAGE(XMITQ)
                   DEF CHANNEL(FROM.CLUS) CHLTYPE(SDR) CONNAME('localhost(1236)') XMITQ(QM3)

                   ON QM3 :

                   DEF CHANNEL(FROM.CLUS) CHLTYPE(RCVR)

12. Create a local queue Q3 on QM3.

                   DEF QLOCAL(Q3)

Now if an application (App2) connected to QM2 try to post a message to Q3 on QM3, the message will fly all the way to the intended destination. So how did it work ? The queue manager alias defined as a remote queue on QM1 published in the cluster did the trick for us.


Hope this will help beginners who is taking their first steps in MQ. Happy messaging !! 

No comments:

Post a Comment