You are on page 1of 44

IBM WebSphere MQ E2 Level Training Lab Exercises

September 2009

WMQ E2 Level Training - Lab Exercises

Notice 2009 Tata Consultancy Services Ltd. This is a controlled document. Unauthorized access, copying, replication or usage for a purpose other than for which it is intended, are prohibited. All trademarks that appear in the document have been used for identification purposes only and belong to their respective companies.

Confidential

WMQ E2 Level Training - Lab Exercises

Document Revision History


Date Version Author Changes

22-Sep-2009

1.0

Deepa Chandra

Initial Version

Confidential

WMQ E2 Level Training - Lab Exercises

About this Manual


Purpose
This document intends to provide insight into WebSphere MQ basic concepts through hands-on exercises. Concepts introduced in the document include Distributed Queuing along with few important features of MQI Configuring MQ for Triggering (Channel-Level and Queue-Level) Usage of Queue Manager Alias and Reply-To Queue Alias Syncpoint Control WebSphere MQ Clients

Intended Audience
This document is intended for administrators working on WebSphere MQ products. It is also intended to act as a reference for developers to improve the overall understanding of the product.

Prerequisites
Completion of WebSphere MQ E1-Level Training / Good understanding of WebSphere MQ concepts Familiarity with MQSC commands Basic understanding of the Java programming language Basic understanding of operating system concepts Hardware - Minimum 1 GB RAM (1.6 GHz Pentium M or higher), 4 GB Hard Disk free disk space Software o Window XP OS with service pack 2 or Windows 2K Professional o Installable for WebSphere MQ v6.0 o RAD or Eclipse IDE o 'RFHUtil' utility

Confidential

WMQ E2 Level Training - Lab Exercises

CONTENTS
1 MQ Lab Exercises Day 1...................................................................................... 5
1.1 1.2 1.3 1.4 1.5 ASSIGNMENT 1: CLUSTER SETUP DEFINE REPOSITORIES ....................................................... 5 ASSIGNMENT 2: CLUSTER SETUP ADD QUEUE MANAGERS TO CLUSTER............................... 9 ASSIGNMENT 3: CLUSTER QUEUE SETUP ............................................................................... 12 ASSIGNMENT 4: MULTIPLE QUEUE OCCURRENCE PUT MESSAGES TO CLUSTER QUEUE ..... 14 ASSIGNMENT 5: WORKLOAD BALANCING .............................................................................. 16

MQ Lab Exercises Day 2.................................................................................... 18


2.1 2.2 2.3 ASSIGNMENT 1: OVERLAPPING CLUSTERS ............................................................................. 18 ASSIGNMENT 2: MULTI-CLUSTER QUEUE SETUP ................................................................... 21 ASSIGNMENT 3: MULTI-CLUSTER QUEUE SETUP CLUSTER ALIAS QUEUE .......................... 23

MQ Lab Exercises Day 3.................................................................................... 26


3.1 3.2 ASSIGNMENT 1: OVERLAPPING CLUSTERS WITH DISTRIBUTED QUEUING .............................. 26 ASSIGNMENT 2: TEMPORARY REMOVAL OF QUEUE MANAGER FROM CLUSTER .................... 30

MQ Lab Exercises Day 4.................................................................................... 33


4.1 4.2 4.3 4.4 4.5 ASSIGNMENT 1: MESSAGE CHANNEL REQUESTER-SENDER (CALLBACK COMBINATION) .... 33 ASSIGNMENT 2: MEDIA RECOVERY RECORD MEDIA IMAGE OF MQOBJECT ....................... 35 ASSIGNMENT 3: MEDIA RECOVERY LOCATE QUEUE FILE ................................................... 36 ASSIGNMENT 4: MEDIA RECOVERY RECREATE DAMAGED MQOBJECT .............................. 38 ASSIGNMENT 5: USAGE OF DYNAMIC QUEUE TEMPORARY AND PERMANENT .................... 39

Confidential

WMQ E2 Level Training - Lab Exercises

1
1.1

MQ Lab Exercises Day 1


Assignment 1: Cluster Setup Define Repositories

Purpose: A cluster defines a group of queue managers where every queue manager can make the queues that they host accessible to other queue managers in the cluster. Queue managers can communicate with each other without creating explicit channels or transmission queues for each destination queue manager. This exercise illustrates how to set up repositories for a cluster. Instruction: Create a cluster, PLANETS with queue managers, JUPITER and MARS as the full repositories.

On queue manager, JUPITER, o Alter the queue manager to make it a full repository for the cluster, PLANETS o Define cluster receiver channel to itself o Define cluster sender channel to MARS On queue manager, MARS, o Alter the queue manager to make it a full repository for the cluster, PLANETS o Define cluster receiver channel to itself o Define cluster sender channel to JUPITER Solution: On queue manager, JUPITER,
Confidential 5

WMQ E2 Level Training - Lab Exercises

On queue manager, MARS,

Confidential

WMQ E2 Level Training - Lab Exercises

The channels will automatically start running once the corresponding cluster sender and cluster receiver pair is created. If not, check the definition of the cluster channels

Confidential

WMQ E2 Level Training - Lab Exercises

Issue following MQSC command on the queue managers to check if the cluster has been set up successfully: DIS CLUSQMGR (*) CLUSTER (PLANETS)

Confidential

WMQ E2 Level Training - Lab Exercises

1.2

Assignment 2: Cluster Setup Add Queue Managers to Cluster


Purpose: This exercise demonstrates how to include queue managers to an existing cluster. Instruction: Add queue managers, SATURN and PLUTO as partial repositories to the cluster, PLANETS. On queue manager, SATURN, o Define cluster receiver channel to itself o Define cluster sender channel to one of the full repositories (e.g. JUPITER) On queue manager, PLUTO, o Define cluster receiver channel to itself o Define cluster sender channel to one of the full repositories (e.g. JUPITER Solution: On queue manager, SATURN,

Confidential

WMQ E2 Level Training - Lab Exercises

On queue manager, PLUTO,

Issue following MQSC command on the queue managers to check if the queue managers have been added successfully to the cluster: DIS CLUSQMGR (*) CLUSTER (PLANETS)
Confidential 10

WMQ E2 Level Training - Lab Exercises

On the full repositories, all the four queue managers will be visible.

A partial repository, upon joining a cluster, learns about the queue managers in the cluster that hold full repositories. The queue manager can then request information from any of the repositories when they first need to access another queue or queue manager, and also request to be notified of any changes concerning that queue or queue manager. On each of the partial repositories, the information about the other partial repository queue manager will be unavailable at the moment till it needs to access that queue manager.

Confidential

11

WMQ E2 Level Training - Lab Exercises

1.3

Assignment 3: Cluster Queue Setup


Purpose: A cluster queue is a queue hosted by any of the queue managers in a cluster which is accessible to other cluster queue managers for putting messages. This exercise demonstrates how to set up a cluster queue. Instruction: Create local queue, SATELLITE on queue managers, SATURN and PLUTO and add them to the cluster, PLANETS. Check how many instances of the cluster queue are available on all/any of the queue managers. Solution: On queue manager, SATURN,

Confidential

12

WMQ E2 Level Training - Lab Exercises

On queue manager, PLUTO,

Issue the following MQSC command on the queue managers, DIS QCLUSTER (SATELLITE) Two instances of the queue will be seen, with only the CLUSQMGR value differing

Confidential

13

WMQ E2 Level Training - Lab Exercises

1.4

Assignment 4: Multiple Queue Occurrence Put Messages to Cluster Queue


Purpose: The same cluster queue definition can be hosted by more than one participating queue managers in a cluster. This exercise demonstrates what happens when an application tries to access and put messages to the cluster queue definition through a cluster queue manager other than those hosting the queue. Instruction: Through the utility, RFHUtil, connect to JUPITER and put 5 messages to queue SATELLITE. Check the current depth on the queue SATELLITE on both the queue managers, SATURN and PLUTO. Solution: Open RFHUtil. Mention Queue Manager Name as JUPITER and Queue Name as SATELLITE. Click on Read File and upload the message file. Click on Write Q 5 times.

Confidential

14

WMQ E2 Level Training - Lab Exercises

All messages will be on queue, SATELLITE of one queue manager (say, PLUTO). The current depth of the queue on the other queue manger (SATURN) shows zero messages. This is because the DEFBIND attribute for both the queues is set as OPEN. Therefore on MQOPEN, the destination queue instance is selected and will not be changed until MQCLOSE. Hence all messages are sent to the same queue instance.

Confidential

15

WMQ E2 Level Training - Lab Exercises

1.5

Assignment 5: Workload Balancing


Purpose: This exercise illustrates how to achieve workload balancing using round-robin routine when multiple instances of the cluster queue definition exists in the cluster. Instruction: Change the queue properties to enable round-robin distribution of messages, by changing the DEFBIND attribute value from OPEN to NOTFIXED. Open a new instance of RFHUtil. Put 5 more messages on queue, SATELLITE through queue manager JUPITER. Solution:

Confidential

16

WMQ E2 Level Training - Lab Exercises

The messages will alternate between the queues, SATELLITE on queue managers, SATURN and PLUTO.

Confidential

17

WMQ E2 Level Training - Lab Exercises

2 MQ Lab Exercises Day 2


2.1 Assignment 1: Overlapping Clusters
Purpose: Overlapping clusters are useful in allowing different organizations/departments to be administered separately or for creating/managing different environments. This exercise demonstrates how to set up two overlapping clusters with a common repository. Instruction: Create another cluster, CHOCOLATE with queue manager, MARS as the full repository and two participating queue managers, KITKAT (Port # 6001) and SNICKERS (Port # 6002).

Solution: On queue manager, MARS, o Create a namelist for the clusters, PLANETS and CHOCOLATE o Alter the queue manager to make it a full repository for the two clusters o Define cluster receiver channel to itself, for cluster, CHOCOLATE
Confidential 18

WMQ E2 Level Training - Lab Exercises

Alternately you can use the same cluster sender and cluster receiver channels for more than one clusters. In that case, use the attribute CLUSNL instead of CLUSTER on the channels. Follow solution for Assignment - Error! Reference source not found. for adding queue managers, KITKAT and SNICKERS to the cluster. Issue following MQSC command on the queue managers to check if the clusters have been set up successfully: DIS CLUSQMGR (*) CLUSTER (CHOCOLATE) DIS CLUSQMGR (*) CLUSTER (*)

Confidential

19

WMQ E2 Level Training - Lab Exercises

Confidential

20

WMQ E2 Level Training - Lab Exercises

2.2

Assignment 2: Multi-Cluster Queue Setup

Purpose: This exercise demonstrates how to set up a cluster queue belonging to multiple clusters. Instruction: Create local queue, DARKCHOCOLATE on queue manager, KITKAT belonging to cluster, CHOCOLATE. Create another local queue, COMET on MARS and add it to the clusters, PLANETS and CHOCOLATE. Issue the following MQSC command on the queue managers, MARS & SATURN and check the outcome. DIS QCLUSTER (DARKCHOCOLATE) DIS QCLUSTER (COMET) Solution:

Issue the following MQSC commands on the queue manager, MARS DIS QCLUSTER (COMET) Two instances of the queue will be seen, one belonging to cluster PLANETS and one belonging to CHOCOLATE. DIS QCLUSTER (DARKCHOCOLATE)
Confidential 21

WMQ E2 Level Training - Lab Exercises

One instance of the queue will be seen

Issuing amqsput COMET SATURN at the command prompt and pressing enter twice, will make the queue, COMET be known to SATURN. Issue the following MQSC commands on the queue manager, SATURN DIS QCLUSTER (COMET) One instance of the queue will be seen DIS QCLUSTER (DARKCHOCOLATE) No instance of the queue is seen since the queue, DARKCHOCOLATE is in cluster CHOCOLATE of which SATURN is not a part of.

Confidential

22

WMQ E2 Level Training - Lab Exercises

2.3

Assignment 3: Multi-Cluster Queue Setup Cluster Alias Queue

Purpose: In case of overlapping clusters, it is possible to use an alias queue belonging to one cluster to put messages on a local queue hosted by a different queue manager and belonging to another cluster. This exercise illustrates the same. Instruction: Create an alias queue, MYALIAS on queue manager, MARS belonging to cluster, CHOCOLATE. The base queue is to be SATELLITE. DEF QA (MYALIAS) + CLUSTER (CHOCOLATE) + TARGQ (SATELLITE) a) Put a message on to queue MYALIAS using amqsput from queue manager KITKAT. Check where the messages have been delivered. b) Rectify the error Solution:

Confidential

23

WMQ E2 Level Training - Lab Exercises

a) amqsput MYALIAS KITKAT The messages will land on the dead letter queue of MARS. The dead letter handler will show the reason as MQRC 2082 (MQRC_UNKNOWN_ALIAS_BASE_Q). The DEFBIND option of the alias queue is set to OPEN. Hence at MQOPEN, MYALIAS requires a base queue which can physically hold the messages. SATELLITE is a clustered queue residing in a remote queue manager; hence the error.

b) On queue manager, MARS, ALTER QA (MYALIAS) + DEFBIND (NOTFIXED) The error will be rectified and the messages will be sent to one of the instances of queue, SATELLITE.
Confidential 24

WMQ E2 Level Training - Lab Exercises

Confidential

25

WMQ E2 Level Training - Lab Exercises

3 MQ Lab Exercises Day 3


3.1 Assignment 1: Overlapping Clusters with Distributed Queuing

Purpose: To demonstrate how a clustered set up can work along with a point-to-point setup. Instruction:

For the setup mentioned in the above figure, a) From queue manager VENUS (Port # 8005), send a message to queue, SATELLITE on SATURN. (Hint: Use Remote Queue Definition) b) From queue manager SATURN, send a message to queue, V on VENUS. (Hint: Use Queue Manager Alias) c) From queue manager KITKAT, send a message to queue, V on VENUS. (Hint: Use Queue Manager Alias) d) From queue manager VENUS, send a message to queue, DARKCHOCOLATE on KITKAT. Solution: Ensure that the connectivity between queue managers VENUS and JUPITER exists (via distributed queuing). Create local queue, V on VENUS
Confidential 26

WMQ E2 Level Training - Lab Exercises

a) On VENUS, create a remote queue definition pointing to queue, SATELLITE

amqsput SATELLITE VENUS The messages will land on queue SATELLITE on SATURN.

b) On JUPITER, create a queue manager alias pointing to VENUS

Confidential

27

WMQ E2 Level Training - Lab Exercises

Through API exerciser, connect to SATURN. In advanced mode for MQOPEN, specify ObjectName V ObjectQMgrName VENUS.QM Put messages OR On SATURN, define a remote queue definition with RNAME as V and RQMNAME as VENUS.QM

amqsput V SATURN c) On MARS, create a queue manager alias pointing to VENUS.QM on JUPITER

Confidential

28

WMQ E2 Level Training - Lab Exercises

Note: Since the xmitq is empty, it will take SYSTEM.CLUSTER.TRANSMIT.QUEUE as the transmission queue. Through API exerciser, connect to KITKAT. In advanced mode for MQOPEN, specify ObjectName V ObjectQMgrName VENUS.RQM Put messages OR On KITKAT, define a remote queue definition with RNAME as V and RQMNAME as VENUS.RQM

amqsput V KITKAT d) On VENUS, create a remote queue definition to queue, DARKCHOCOLATE with RQMNAME as KITKAT.QM

Confidential

29

WMQ E2 Level Training - Lab Exercises

On MARS, create a queue manager alias, KITKAT.QM to queue manager, KITKAT

amqsput DARKCHOCOLATE VENUS

3.2

Assignment 2: Temporary Removal of Queue Manager from Cluster

Purpose: To demonstrate how to remove a queue manager temporarily from the cluster and to re-instate it back into the cluster. The command for temporary removal of queue manager can be useful if the queue manager has to be brought down for maintenance. Instruction:

Confidential

30

WMQ E2 Level Training - Lab Exercises

Remove the queue manager, SATURN from cluster, PLANETS temporarily. Put 2 messages to the queue, SATELLITE and check to which queue instance the messages are delivered. Solution: On queue manager, SATURN, SUSPEND QMGR CLUSTER (PLANETS) The messages sent to queue, SATELLITE will no longer be routed to SATURN. Although it is suspended from the cluster, all information about SATURN is preserved in the repositories. The MQSC command, DIS CLUSQMGR (*) CLUSTER (PLANETS) SUSPEND shows if the queue manager is suspended or not

Confidential

31

WMQ E2 Level Training - Lab Exercises

Put messages using the following command: amqsput SATELLITE JUPITER The messages will be delivered only to the queue, SATELLITE on queue manager PLUTO. To resume the queue manager in the cluster, issue RESUME QMGR CLUSTER (PLANETS)

Note: Alternately use the attribute CLUSNL instead of CLUSTER to suspend or resume queue managers from multiple clusters.

Confidential

32

WMQ E2 Level Training - Lab Exercises

4 MQ Lab Exercises Day 4


4.1 Assignment 1: Message Channel Requester-Sender (Callback combination)

Purpose: The most common combination involving message channels is when a sender initiates a communication with a receiver and sends messages to it. However, there exists another combination where a requester can initiate a communication with a sender. The sender terminates the communication connection promptly and starts another communication connection with the requester (using its channel definition details) and sends messages to it. This is called a callback combination. This exercise explores the callback mechanism involving the message channel pairRequester-Sender

Instruction: Create a requester channel (A.TO.B) on queue manager, JUPITER. Create a sender channel (A.TO.B) on queue manager, MARS. (Ensure that if a sender channel exists from MARS to JUPITER, it is in stopped state) Through the API exerciser, connect to MARS. Click on Open queue option, in advanced mode. Specify ObjectName - J ObjectQMgrName - JUPITER Put 5 messages. Check where the messages are available. Solution: On queue manager, JUPITER,

Confidential

33

WMQ E2 Level Training - Lab Exercises

On queue manager, MARS,

Put 5 messages through API exerciser. The messages will stay in the transmission queue, JUPITER on queue manager, MARS.

Start the requester channel on queue manager, JUPITER. This automatically starts the sender channel and messages will be delivered to queue, J on queue manager JUPITER.

Confidential

34

WMQ E2 Level Training - Lab Exercises

4.2

Assignment 2: Media recovery Record Media Image of MQObject


Purpose: Media recovery re-creates objects from information recorded in a linear log. This exercise demonstrates how to record the media image of a local queue. Instruction: Create a queue manager, COMPANY with linear logging specified as the logging option (Port Number 7001). Create local queue, ADMIN. Record the media image of the queue using the following command: rcdmqimg [-m QMgrName] -t ObjType [GenericObjName] Solution: Create queue manager with linear logging

Confidential

35

WMQ E2 Level Training - Lab Exercises

Create local queue, ADMIN

The following control command records the media image of the queue, ADMIN rcdmqimg m COMPANY t queue ADMIN

4.3

Assignment 3: Media recovery Locate Queue File


Purpose:
Confidential 36

WMQ E2 Level Training - Lab Exercises

This exercise explains how to locate a queue file and demonstrates what error is shown when a damaged object is accessed. Instruction: Delete the queue file for ADMIN. The path of the queue file can be determined using the command: dspmqfls [-m QMgrName] [-t ObjType] GenericObjName Issue the display command on MQSC mode. Discuss the result. Solution: o The control command, dspmqfls shows the path where the queue file for ADMIN is stored.

Delete the file. o Restart queue manager, COMPANY

o On queue manager, COMPANY, Display the queue, ADMIN

The result shows the error AMQ8149: WebSphere MQ Object damaged. If the queue is accessed for putting messages, it returns the error code 2101 (MQRC_OBJECT_DAMAGED).

Confidential

37

WMQ E2 Level Training - Lab Exercises

4.4

Assignment 4: Media recovery Recreate Damaged MQObject


Purpose: This exercise explains how to recreate a damaged object manually using the rcrmqobj command. This command replays the records in the log to re-create the MQ object. The object is re-created from its latest image found in the log, together with all applicable log events between the time the image was saved and the time the re-create command was issued. Instruction: Recover the queue, ADMIN using the rcrmqobj command: rcrmqobj [-m QMgrName] -t ObjType [GenericObjName] Solution: A damaged object can be recreated using the rcrmqobj command. rcrmqobj -m COMPANY -t queue ADMIN On queue manager, COMPANY, DIS QL (ADMIN) The queue attributes will now be seen.

Confidential

38

WMQ E2 Level Training - Lab Exercises

4.5

Assignment 5: Usage of Dynamic Queue Temporary and Permanent


Purpose: Dynamic queues are useful in situations where the queue is no longer required once the application ends. When an application program issues an MQOPEN call to open a model queue, the queue manager dynamically creates an instance of a local queue with the same attributes as the model queue. Depending on the value of the DefinitionType field of the model queue, the queue manager creates either a temporary or permanent dynamic queue. If the DefinitionType field of the model queue is TEMPDYN, the instance of the local queue created will be deleted once the application ends. If the DefinitionType field of the model queue is PERMDYN, the instance of the local queue created will continue to exist even after the application ends. This exercise illustrates a sample java program (using MQ API commands) through which a message is put to a temporary or permanent dynamic queue (based on the input argument value). Instruction: On queue manager, VENUS, create a permanent dynamic queue, DYN.SAMPLE.
Confidential 39

WMQ E2 Level Training - Lab Exercises

DEF QMODEL (DYN.SAMPLE) + DEFTYPE (PERMDYN) Import the following zip file onto a new workspace on an eclipse based IDE.

Build the project and run MessagePutOnDynamicQueue specifying two arguments, where args[0] Instance of the local queue to be created args[1] Name of the model queue Run the java program twice, once with a temporary dynamic queue name (e.g. SYSTEM.DEFAULT.MODEL.QUEUE) for args[1] and then with a permanent dynamic queue name (e.g. DYN.SAMPLE). Once the message Message put successful is seen on console, open command prompt, RUNMQSC <QueueManagerName> DIS Q (QueueName) where QueueName - Instance of the local queue. Check the CURDEPTH attribute. END amqsbcg <QueueName> <QueueManagerName> This displays the contents of the message. Solution: On queue manager, VENUS, create a permanent dynamic queue, DYN.SAMPLE.

Run the java program specifying TEMPQ and SYSTEM.DEFAULT.MODEL.QUEUE as the arguments

Confidential

40

WMQ E2 Level Training - Lab Exercises

Once the message Message put successful is seen on console, open command prompt, RUNMQSC VENUS DIS Q (TEMPQ) Check the CURDEPTH attribute. It should be 1. END
Confidential 41

WMQ E2 Level Training - Lab Exercises

amqsbcg TEMPQ VENUS Note: The queue, TEMPQ will be deleted once the application ends. Run the java program specifying PERMQ and DYN.SAMPLE as the arguments. Once the message Message put successful is seen on console, open command prompt, RUNMQSC VENUS DIS Q (PERMQ) Check the CURDEPTH attribute. It should be 1. END amqsbcg PERMQ VENUS The queue, PERMQ can be viewed in the MQSC prompt or at the MQExplorer even after the application has terminated.

Confidential

42

WMQ E2 Level Training - Lab Exercises

Confidential

43

You might also like