add

IBM Websphere MQ Pub Sub Model Cluster setup scenario

Demonstrates Pub Sub Clustering mode of topics.

MQ Pub Sub Cluster

To quickly get into the concept of Pub/Sub model, let me demonstrate two sets of scenarios for better picture rather than getting into theory.


In order to demonstrate this scenario, lets work out on a Queue manager cluster that’s dedicated to carry loads of telecom offer price messages in real time. To keep it simple, lets create our QM cluster with two full Repo queue managers ( recommendation is to have at least two full repos in case, one full repo QM is down) and one partial repo queue manager as shown in below picture.

We’ll create two queue managers with names : NYEPC and DALLASEPC, TNEPC participating in cluster with Name : EPCPRICES. We will make them as Full repo so that they can hold the complete knowledge of cluster EPCPRICES as follows.


QM : NYEPC , TNEPC , DALLASEPC


create and start queue managers.

crtmqm NYEPC

crtmqm NTEPC

crtmqm DALLASEPC

strmqm NYEPC

strmqm NTEPC

strmqm DALLASEPC

Configuring the queue manager : NYEPC


a. Launch the MQSC interface.In the command line, enter the following commands:
runmqsc NYEPC

b. Define a listener.

DEFINE LISTENER(NY.EPC.LSTNR) TRPTYPE(TCP) CONTROL(QMGR) PORT(1111)

c. Start the listener.

START LISTENER(NY.EPC.LSTNR)

2. Set the queue manager as a full repository for the cluster.

ALTER QMGR REPOS(EPCPRICES)

3. Define a receiver channel for NYEPC, to allow other queue managers in the cluster to communicate with it.

    DEFINE CHANNEL(TO.NYEPC) CHLTYPE(CLUSRCVR) TRPTYPE(TCP) 
    CONNAME('localhsot(1111)') CLUSTER(EPCPRICES)
    DESCR('TCP Cluster-receiver channel for queue manager NYEPC')

4. Define a sender channel from NYEPC to DALLASEPC, to allow the two full repositories to exchange information.

  DEFINE CHANNEL(TO.DALLASEPC) CHLTYPE(CLUSSDR) TRPTYPE(TCP) 
  CONNAME('localhost(2222)') CLUSTER(EPCPRICES)
  DESCR('TCP Cluster-sender channel from NYEPC to queue manager DALLASEPC')


Configuring the queue manager : DALLASEPC


Use the MQSC interface to define a listener and a receiver channel for DALLASEPC, to set the queue manager as a full repository for the cluster, and to define a sender channel from DALLASEPC to NYEPC so the two full repositories can exchange information.


1. Define and start a listener for DALLASEPC.

a. Launch the MQSC interface.In the command line, enter the following command:

     runmqsc DALLASEPC

b. Define a listener.Enter the following MQSC command:

   DEFINE LISTENER(DALLAS.EPC.LSTNR) TRPTYPE(TCP) CONTROL(QMGR) PORT(2222)

c. Start the listener.Enter the following MQSC command:

         START LISTENER(DALLAS.EPC.LSTNR)

2. Set the queue manager as a full repository for the cluster.

         ALTER QMGR REPOS(EPCPRICES)

3. Define a receiver channel for DALLASEPC, to allow other queue managers in the cluster to communicate with
it.Enter the following MQSC command:

        DEFINE CHANNEL(TO.DALLASEPC) CHLTYPE(CLUSRCVR) TRPTYPE(TCP) 
        CONNAME('localhost(2222)') CLUSTER(EPCPRICES)
        DESCR('TCP Cluster-receiver channel for queue manager DALLASEPC')

4. Define a sender channel from DALLASEPC to NYEPC, to allow the two full repositories to exchange information.
Enter the following MQSC command:

        DEFINE CHANNEL(TO.NYEPC) CHLTYPE(CLUSSDR) TRPTYPE(TCP) 
        CONNAME('localhost(1111)’) CLUSTER(EPCPRICES)
        DESCR('TCP Cluster-sender channel from DALLASEPC to NYEPC')

configure Partial Repo queue manager : TNEPC


Use the MQSC interface to define a listener and a receiver channel for TNEPC. Join TNEPC into the cluster by defining a sender channel from TNEPC to one of the full repository queue managers.


1. Define and start a listener for TNEPC.

a. Launch the MQSC interface.

runmqsc TNEPC

b. Define a listener.

DEFINE LISTENER(TN.EPC.LSTNR) TRPTYPE(TCP) CONTROL(QMGR) PORT(3333)

c. Start the listener.

START LISTENER(TN.EPC.LSTNR)

2. Define a receiver channel for TNEPC, to allow other queue managers in the cluster to communicate with it.

   DEFINE CHANNEL(TO.TNEPC) CHLTYPE(CLUSRCVR) TRPTYPE(TCP) 
   CONNAME('localhost(3333)') CLUSTER(EPCPRICES)
   DESCR('TCP Cluster-receiver channel for queue manager TNEPC')

3. Define a sender channel from TNEPC to one of the full repository queue managers (in this case, DALLASEPC).This joins TNEPC into the cluster.

   DEFINE CHANNEL(TO.NYEPC) CHLTYPE(CLUSSDR) TRPTYPE(TCP) 
   CONNAME('localhost(1111)') CLUSTER(EPCPRICES)
   DESCR('TCP Cluster-sender channel from TNEPC to NYEPC')

4. Validate that TNSEPC has successfully joined the cluster.

DISPLAY CLUSQMGR(*) QMTYPE

This command returns three entries, one each for NYEPC, DALLASEPC and TNEPC. NYEPC and DALLASEPC should have a QMTYPE
of REPOS, and TNEPC should have a QMTYPE of NORMAL.

Now since we are done with the cluster setup of Queue managers, lets create the important object for pub/sub model called Topic.
we will create a topic with name EPCPRICE on Partial repo TNEPC and add it to the cluster EPCPRICES we created some time back with direct route.

1.Launch the MQSC interface for the Queue manager TNEPC.

runmqsc TNEPC

b. Define the cluster topic EPCPRICES.

DEFINE TOPIC(EPCPRICE) TOPICSTR(’/epc/offers/prices’) CLUSTER(EPCPRICES) CLROUTE(DIRECT)

c. exit the MQSC interface for TNEPC.

2. Verify the topic definition on NYEPC.

runmqsc NYEPC

verify the  cluster state for cluster topic EPCPRICE. CLSTATE attribute must show the value as ACTIVE.

DISPLAY TCLUSTER(EPCPRICE) CLSTATE


Testing :


For testing this setup, open 3 terminals. lets use Terminal 1 to run a publisher sample and other two terminals each for 2 subscribers.

Terminal 1 : 
amqspub  /epc/offers/prices NYEPC

Terminal 2 and terminal 3 :
amqssub /epc/offers/prices DALLASEPC
amqssub /epc/offers/prices TNEPC

Reference : IBM MQ v8 Info center. https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.pro.doc/q005130_.htm


What’s next ?

Publish/Subscribe Hierarchy scenario

Written by Ramesh Metta


Leave a Reply

Your email address will not be published. Required fields are marked *

*
*