SAS 9.1.3 Integration Technologies » Developer's Guide


Application Messaging Overview
Supported Messaging Interface Versions
WebSphere MQ Configuration and Usage
Configuring WebSphere MQ with the WebSphere MQ Explorer
Polling Message Queues from the Object Spawner
Configuring Multiple Clients To Read From a Single Queue
Configuring WebSphere MQ to Trigger SAS
WebSphere MQ Interface
Writing WebSphere MQ Applications
WebSphere MQ Code Samples
WebSphere MQ CALL Routines
MSMQ Interface
Writing MSMQ Applications
MSMQ Code Samples
MSMQ Call Routines
Common Messaging Interface
Writing Applications
Using TIB/Rendezvous with the Common Interface
TIB/Rendezvous Coding Example
TIB/Rendezvous Certified Messaging Coding Example
Using a Repository with Application Messaging
SAS CALL Routines for the Common Interface
Attachment Layout for Websphere MQ and MSMQ Through Common Messaging Interface
Attachment Layout for TIB/Rendezvous
Attachment Error Handling for Common Messaging Interface
Application Messaging

Configuring 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 only be retrieved 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. Note that message queuing applications on the machine where the queue manager is installed can access the queues directly, and they do not need to be configured as clients, although they can be.

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.

Defining a Queue Manager for Multiple Clients

To configure the queue manager on the server:

  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 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. For 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 New arrow Local Queue and enter the queue name and properties. For example:

      Create Local Queue window

  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. For 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 MYQMGR arrow Advanced to expand the list. Right-click Channels, select NEW arrow Server Connection Channel and enter the channel name. For example:

      Create Server Connection Channel window

  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:
         set MQSERVER=ChannelName/TransportType/ConnectionName

      For 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. For example:

         set MQSERVER=SERVER.CHANNEL1/TCP/10.12.0.0(1414)

    • For UNIX:
         export MQSERVER=ChannelName/TransportType/ConnectionName

      For 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 using the WebSphere MQ Functional Interface. This line should go at the beginning of the application before the DATA step, for example:

       %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. See the documentation in the WebSphere MQ Information Center for additional information about the MCAUSER ID, Access Control, and configuring queue managers, queues, channels, clients, and other objects.