AMQSCLM: Preparing and running the sample

In order to run the cluster queue monitoring sample, you must configure the queue manager to securely accept incoming connection requests from applications running in client mode.

Before you begin

The following steps must be completed before running the cluster queue monitoring sample.

  1. Create a working queue on each queue manager for the internal use of the sample.

    Each instance of the sample needs a local non-cluster queue for exclusive internal use. You can choose the name of the queue. The example uses the name AMQSCLM.CONTROL.QUEUE. For example, on Windows, you can create this queue by using the MQSC command

    DEFINE QLOCAL(AMQSCLM.CONTROL.QUEUE)
    You can leave the values of MAXDEPTH and MAXMSGL as default.

  2. Create a directory for error and information message logs.
    The sample writes diagnostic messages to report files. You must choose a directory in which to store the files. For example, on Windows, you can create a directory using the following command:
    mkdir C:\AMQSCLM\rpts
    The report files created by the sample have the following naming convention:
    QmgrName.ClusterName.RPT0n.LOG
  3. (Optional) Define the cluster queue monitoring sample as an IBM® WebSphere® MQ service.
    To monitor queues, the sample must always be running. To ensure that the cluster queue monitoring sample is always running, you can define the sample as a queue manager service. Defining the sample as a service means that AMQSCLM is started when the queue manager starts. You can use the following RUNMQSC example to define the cluster queue monitoring sample as an IBM WebSphere MQ service.
    define service(AMQSCLM) +
    	descr('Active Cluster Queue Message Distribution Monitor - AMQSCLM') +
    	control(qmgr) +
    	servtype(server) +
    	startcmd('<Install Root>\tools\c\samples\Bin\AMQSCLM.exe') +
     startarg('-m +QMNAME+ -c CLUSTER1 -q ABC* -r AMQSCLM.CONTROL.QUEUE -l c:\AMQSCLM\rpts') +
     stdout('C:\AMQSCLM\rpts\+QMNAME+.TSTCLUS.stdout.log') +
     stderr('C:\AMQSCLM\rpts\+QMNAME+.TSTCLUS.stderr.log')
    where <Install Root> is the location of your installation.
    Definition Description
    service Specifies the service name. You can choose the service name.
    descr Specifies a textual description of the service.
    control Indicates that the service starts and stops at the same time as the queue manager.
    servtype Indicates a server service object, meaning only one instance, can be executed at a time for this queue manager.
    startcmd Specifies the location and name of the program.
    startarg Specifies the arguments of the sample. Note the use of +QMNAME+. The name of the queue manager is automatically substituted.
    stdout The fully qualified file name to which standard output is redirected. The sample writes to this file only messages confirming that the sample has terminated. The sample does this because the standard error file has already closed in an earlier stage of the sample termination process.
    stderr The fully qualified file name to which standard error output is redirected. The sample writes to the standard error file any error messages prior to termination of the sample.

About this task

This task enables you to start and stop the cluster queue monitoring sample in different ways. It also enables you to run the sample in a mode that generates report files containing statistical information about the queues being monitored.
The sample program can be run by using the following command.
AMQSCLM -m QMgrName -c ClusterName (-q QNameMask | -f QListFile) -r MonitorQName 
[-l ReportDir] [-t] [-u ActiveVal] [-i Interval] [-d] [-s] [-v]
Argument Variable Further Information
-m QMgrName The queue manager to monitor.
-c ClusterName The cluster containing the queues to monitor.
-q QNameMask The queue, or queues, to monitor. A trailing * monitors all queues with names that match zero or more trailing characters.
-f QListFile The full path and file name of a file containing a list of queue names of queue name masks to monitor. The file must contain one queue name/mask per line. You can specify -q or -f, but not both.
-r MonitorQName The local queue being used exclusively by the sample.
-l ReportDir The directory path in which to store logged information messages in a set of wrapping<fn>For each queue manager and queue combination a report file is generated that is capped at a certain size. The logger always writes into the same file, but it also keeps the two previous versions of the file.</fn> report files.
-t (Optional) Enables the transfer of queued messages from inactive local queues to active queues. If not enabled, only new messages entering the cluster are dynamically routed to active instances of a queue.
-u ActiveVal (Optional) Automatically switches the CLWLUSEQ property of a monitored queue instance to ANY when it is inactive, and to the ActiveVal property when active. ActiveVal can be LOCAL or QMGR. If this argument is not set in a system where putting applications connect to the same queue manager, or where message transfer is enabled, then monitored queues must have a CLWLUSEQ value of ANY, or QMGR with the queue manager having a value of ANY.
-i Interval (Optional) The time interval in seconds, at which the monitor checks the queues. Default is 300 seconds (5 minutes).
-d (Optional) Enables additional diagnostic output. Debug output might be useful when initially configuring the system, or when working with the sample code.
-s (Optional) Enables minimal statistical output per interval.
-v (Optional) Log report information to standard out, in addition to the report files.
Argument list examples:
-m QMGR1 -c CLUS1 -f c:\QList.txt -r CLMQ -l c:\amqsclm\rpts -s
-m QMGR2 -c CLUS1 -q ABC* -r CLMQ -l c:\amqsclm\rpts -i 600
-m QMGR1 -c CLUSDEV -q QUEUE.* -r CLMQ -l c:\amqsclm\rpts -t -u QMGR -d
Example queue list file:
Q1
QUEUE.*
ABC
ABD

Procedure

  1. Start the cluster queue monitoring sample. You can start the sample in one of the following ways:
    • Use a command prompt with the appropriate user authorizations.
    • Use the MQSC START SERVICE command, if the sample is configured as an IBM WebSphere MQ service.
    The argument list is the same in both cases.
    The sample does not start monitoring the queues for 10 seconds after the program is initialized. This delay allows consuming applications to connect to the monitored queues first, preventing unnecessary changes to the active state of the queue.
  2. Stop the cluster queue monitoring sample. The sample automatically stops when the queue manager is stopped, stopping, quiescing, or if the connection to the queue manager is broken. There are ways to stop the sample without ending the queue manager:
    • Configure the local queue used exclusively by the sample to disable the Get function.
    • Send a message with a CorrelId of "STOP CLUSTER MONITOR\0\0\0\0", to the local queue used exclusively by the sample.
    • Terminate the sample process. This might result in the loss of non-persistent messages being transferred to active queues. It might also result in the local queue used by the sample being held open for a number of seconds after the termination. This situation prevents a new instance of the cluster queue monitoring sample from starting immediately.
    If the sample has been started as an IBM WebSphere MQ service, STOP SERVICE has no effect. It is possible to use one of the termination methods described as a configured STOP SERVICE mechanism in the queue manager.

What to do next

Check the status of the sample.

If reporting is enabled, you can review the report files for status. Use the following command to review the most current report file.
QMgrName.ClusterName.RPT01.LOG
To review older report files, use the following commands.
QMgrName.ClusterName.RPT02.LOG
QMgrName.ClusterName.RPT03.LOG  
Report files grow to a maximum size of approximately 1 MB. When the RPT01 file fills up, a new RPT01 file is created. The old RPT01 file is renamed to RPT02. RPT02 is renamed to RPT03. The old RPT03 is discarded.
The sample creates information messages in the following situations:
  • At startup
  • At termination
  • When it marks a queue ACTIVE or INACTIVE
  • when it requeues messages from an inactive queue to an active instance, or instances

The sample creates an error message CLMnnnnE to report a problem that requires attention.

Every 30 minutes, the sample reports average processing time per polling interval, and elapsed processing time. This information is held in message CLM0045I.

When statistical messages are enabled -s, the sample reports the following statistical information about each queue check:
  • Time taken to process the queues (in milliseconds)
  • Number of queues checked
  • Number of active/inactive changes made
  • Number of messages transferred
This information is reported in message CLM0048I.

Report files might grow rapidly in debug mode, and quickly wrap. In this situation, the 1-MB size limit for individual files might be exceeded.