Configure Multiple Clients to Read from a Single Queue

The WebSphere MQ interfaces and the message queue polling feature of the object spawner can be used to distribute the processing of messages on a message queue across one or more machines. The result is enhanced performance, load balancing, and hardware redundancy.
Messages can be retrieved only from local queues. In order to enable multiple machines to process messages on a single queue, you must have a full WebSphere MQ (server) installation on the machine that will act as the server. The WebSphere MQ Clients use the queue manager on the server as their queue manager, so any local queues that are defined on that queue manager are also local to the client installations. The WebSphere MQ Clients can connect to a WebSphere MQ server on any supported platform. Message queuing applications on the machine where the queue manager is installed can access the queues directly. Message queuing applications do not need to be configured as clients.
The following diagram illustrates a sample configuration. The queue manager (MYQMGR) is running on Server1 and is managing the queue for each of the WebSphere MQ Clients (CLIENT1, CLIENT2, and CLIENT3). All three clients are communicating with the queue manager through the same server connection channel (SERVER.CHANNEL1). The object spawners on each of the clients can start one or more SAS sessions as needed in order to receive messages from the queue. SAS sessions can also be started by the object spawner and run on the server. A SAS session running on the server does not need to run as a WebSphere MQ Client application; it behaves as a WebSphere MQ server application.
Example Messaging Configuration
Defining a Queue Manager for Multiple Clients
To configure the queue manager on the server, perform the following steps:
  1. Define a queue manager if this has not already been done. In the following example, the queue manager is called MYQMGR.
    crtmqm MYQMGR
  2. Start the queue manager by using the WebSphere MQ Explorer (Windows platforms). You can also use the following command on the command line:
    strmqm MYQMGR
  3. Define one or more local queues that will be used by the applications.
    • To define a local queue from the command line, start the WebSphere MQ command program MQSC. Here is an example:
      runmqsc
      MYQMGR
      DEFINE QLOCAL(LOCAL) DEFPSIST(YES) DESCR('Local Queue')
      Type end to exit MQSC.
    • To define a local queue from the WebSphere MQ Explorer, click MYQMGR to expand the list. Right-click Queues, select Newthen selectLocal Queue and enter the queue name and properties.
  4. Define a server connection channel to enable WebSphere MQ Clients to communicate with MYQMGR. You can also define a separate server connection channel for each client.
    • To define a server connection channel from the command line, start the WebSphere MQ command program MQSC. Here is an example:
      runmqsc MYQMGR
      DEFINE CHANNEL(SERVER.CHANNEL1) CHLTYPE(SVRCONN)
      TRPTYPE(TCP) + MCAUSER(' ') DESCR('Server
      connection channel for Client1')
      Type end to exit MQSC.
    • To define a server connection channel from the WebSphere MQ Explorer, click MYQMGRthen selectAdvanced to expand the list. Right-click Channels, select NEWthen selectServer Connection Channel and enter the channel name.
  5. On each client, install and configure the WebSphere MQ Client. Use the MQSERVER environment variable to define the client connection to the server. The following code shows examples of how to do this in Windows and UNIX operating environments.
    • For Windows, use the following code:
      set
      MQSERVER=ChannelName/TransportType/ConnectionName
      Here is an example:
      set
      MQSERVER=SERVER.CHANNEL1/TCP/server_address(port)
      where server_address is the TCP/IP host name of the server and port is the number of the TCP/IP port on which the server is listening. The default port number is 1414. Here is an example:
      set
      MQSERVER=SERVER.CHANNEL1/TCP/10.12.0.0(1414)
    • For UNIX, use the following code:
      export
      MQSERVER=ChannelName/TransportType/ConnectionName
      Here is an example:
      export
      MQSERVER=SERVER.CHANNEL1/TCP/'10.12.0.0(1414)'
  6. The queue and queue manager values are required in SAS applications that use the WebSphere MQ functional interface. In the previous examples, the queue manager is named MYQMGR, and the queue is named LOCAL. These values are used as follows in the SAS DATA step application:
    hConn=0;
    Name="MYQMGR";
    compCode=0;
    reason=0;
    CALL MQCONN(Name, hConn, compCode, reason);
    
    action = "GEN";
    parms="OBJECTNAME";
    objname="LOCAL";
    call mqod(hod, action, rc, parms, objname);
    
    options="INPUT_SHARED";
    call mqopen(hconn, hod, options, hobj, compCode, reason);
    If a SAS application is running as a WebSphere MQ Client, then you must include the following line of code before making any calls that use the WebSphere MQ Functional Interface. This line should go at the beginning of the application before the DATA step:
    %let MQMODEL=CLIENT;
    data _null_;
    ...
    run;
This example provides basic configuration information for configuring several clients to receive messages from a queue on one server.
For more information, see the WebSphere MQ documentation at www.ibm.com.