Verify the multi-instance queue manager on Windows

Use the sample programs amqsghac, amqsphac and amqsmhac to verify a multi-instance queue manager configuration. This topic provides an example configuration to verify a multi-instance queue manager configuration on Windows Server 2003.

The high availability sample programs use automatic client reconnection. When the connected queue manager fails, the client attempts to reconnect to a queue manager in the same queue manager group. The description of the samples, High availability sample programs, demonstrates client reconnection using a single instance queue manager for simplicity. You can use the same samples with multi-instance queue managers to verify a multi-instance queue manager configuration.

This example uses the multi-instance configuration described in Create a multi-instance queue manager on domain controllers. Use the configuration to verify that the multi-instance queue manager switches over to the standby instance. Stop the queue manager with the endmqm command and use the -s, switchover, option. The client programs reconnect to the new queue manager instance and continue to work with the new instance after a slight delay.

The client is installed in a 400 MB VMware image that is running Windows XP Service Pack 2. For security reasons, it is connected on the same VMware host-only network as the domain servers that are running the multi-instance queue manager. It is sharing the /MQHA folder, which contains the client connection table, to simplify configuration.

Verifying failover using WebSphere MQ Explorer

Before using the sample applications to verify failover, run the WebSphere MQ Explorer on each server. Add both queue manager instances to each explorer using the Add Remote Queue Manager > Connect directly to a multi-instance queue manager wizard. Ensure that both instances are running, permitting standby. Close the window running the VMware image with the active instance, virtually powering off the server, or stop the active instance, allowing switchover to standby instance and reconnectable clients to reconnect.
Note: If you power off the server, make sure that it is not the one hosting the MQHA folder!
Note: The Allow switchover to a standby instance option might not be available on the Stop Queue Manager dialog. The option is missing because the queue manager is running as a single instance queue manager. You must have started it without the Permit a standby instance option. If your request to stop the queue manager is rejected, look at the Details window, possibly there is no standby instance running.

Verifying failover using the sample programs

Choose a server to run the active instance
You might have chosen one of the servers to host the MQHA directory or file system. If you plan to test failover by closing the VMware window running the active server, make sure that it is not the one hosting MQHA!
On the server running the active queue manager instance
  1. Modify ipaddr1 and ipaddr2 and save the following commands in N:\hasample.tst.
    DEFINE QLOCAL(SOURCE) REPLACE
    DEFINE QLOCAL(TARGET) REPLACE
    DEFINE CHANNEL(CHANNEL1) CHLTYPE(SVRCONN)   TRPTYPE(TCP) + 
           MCAUSER(' ') REPLACE
    DEFINE CHANNEL(CHANNEL1) CHLTYPE(CLNTCONN)  TRPTYPE(TCP) + 
           CONNAME('ipaddr1(1414),ipaddr2(1414)') QMNAME(QM1) REPLACE
    START  CHANNEL(CHANNEL1)
    DEFINE LISTENER(LISTENER.TCP) TRPTYPE(TCP) CONTROL(QMGR) 
    DISPLAY LISTENER(LISTENER.TCP) CONTROL
    DISPLAY LSSTATUS(LISTENER.TCP) STATUS
    Note: By leaving the MCAUSER parameter blank, the client user ID is sent to the server. The client user ID must have the correct permissions on the servers. An alternative is to set the MCAUSER parameter in the SVRCONN channel to the user ID you have configured on the server.
  2. Open a command prompt with the path N:\ and run the command:
    runmqsc -m QM1 < hasample.tst
  3. Verify that the listener is running and has queue manager control, either by inspecting the output of the runmqsc command.
     LISTENER(LISTENER.TCP)CONTROL(QMGR)
     LISTENER(LISTENER.TCP)STATUS(RUNNING)
    Or, using the WebSphere MQ Explorer that the TCPIP listener is running and has Control = Queue Manager.
On the client
  1. Map the shared directory C:\MQHA on the server to N:\ on the client.
  2. Open a command prompt with the path N:\ . Set the environment variable MQCHLLIB to point to the client channel definition table (CCDT) on the server:
    SET MQCHLLIB=N:\data\QM1\@ipcc
  3. At the command prompt type the commands:
    start amqsghac TARGET QM1
    start amqsmhac -s SOURCE -t TARGET -m QM1
    start amqsphac SOURCE QM1
    Note: If you have problems, start the applications at a command prompt so that the reason code is printed out on the console, or look at the AMQERR01.LOG file in the N:\data\QM1\errors folder.
On the server running the active queue manager instance
  1. Either:
    • Close the window running the VMware image with the active server instance.
    • Using the WebSphere MQ Explorer, stop the active queue manager instance, allowing switchover to the standby instance and instructing reconnectable clients to reconnect.
  2. The three clients eventually detect the connection is broken, and then reconnect. In this configuration, if you close the server window, it is taking about seven minutes for all three connections to be re-established. Some connections are reestablished well before others.

Results

N:\>amqsphac SOURCE QM1
Sample AMQSPHAC start
target queue is SOURCE
message <Message 1>
message <Message 2>
message <Message 3>
message <Message 4>
message <Message 5>
17:05:25 : EVENT : Connection Reconnecting (Delay: 0ms)
17:05:47 : EVENT : Connection Reconnecting (Delay: 0ms)
17:05:52 : EVENT : Connection Reconnected
message <Message 6>
message <Message 7>
message <Message 8>
message <Message 9>
N:\>amqsmhac -s SOURCE -t TARGET -m QM1
Sample AMQSMHA0 start

17:05:25 : EVENT : Connection Reconnecting (Delay: 97ms)
17:05:48 : EVENT : Connection Reconnecting (Delay: 0ms)
17:05:53 : EVENT : Connection Reconnected
N:\>amqsghac TARGET QM1
Sample AMQSGHAC start
message <Message 1>
message <Message 2>
message <Message 3>
message <Message 4>
message <Message 5>
17:05:25 : EVENT : Connection Reconnecting (Delay: 156ms)
17:05:47 : EVENT : Connection Reconnecting (Delay: 0ms)
17:05:52 : EVENT : Connection Reconnected
message <Message 6>
message <Message 7>
message <Message 8>
message <Message 9>