Chapter Contents


SAS/CONNECT User's Guide

Query for Broadcast Messages

As the members of the work group modify their private copy of the application, they may choose to update their copy by merging any pieces that have been added or modified by others in the work group. Different members may have different schedules for updating their private copy. For example, developers may need adhoc updates that occur when they reach certain points in their development. Testers may require regular updates based on their testing schedules. To meet the individual needs of each member in the work group, message-queuing is used for this portion of the application.

The following code, which was taken from the client portion of the ADM application, allows users to query their queues for existing messages. This portion of the application has been coded to recognize that a message type of 100 means a broadcast message about a new or modified catalog entry type. These messages are broadcast from the ADM server portion of the application to notify users of new or updated catalog entries.

The message contains a status field that indicates whether the entry was added or modified and the name of the entry that was added or modified. If the entry is a new entry, the message also contains the name of the developer who made the addition. If the queue contains one or more messages, the messages are fetched one at a time and a list of entries is constructed. The new or updated entries can then be selected from the list, fetched from the ADM server, and merged into the user's existing catalog.

The following variable would be initialized prior to the code fragment:
qname supplied to the _open method. This variable contains the name of the broadcast queue that will be queried for messages.

Note:   The following code is a portion of an SCL program that is used for illustration purposes only. It is not a complete program.  [cautionend]

   /*                                        */
   /*                                        */

stationid = loadclass('sashelp.connect.station');
qstation = instance(stationid);
call send(qstation, '_open', "TESTQM", rc);

queueid = loadclass('sashelp.connect.queue');
queue = instance(queueid);
call send(queue, '_open', qstation, qname, 
   "FETCH", qrc, "POLL"); 

rc = clearlist(alist);
hlist = makelist();
call send(queue, '_query', eventtype, 
   msgtype, hlist, alist, qrc); 

do while(eventtype ='DELIVERY'); 


      call send(queue, '_getfield' ,parms, 
         qrc, status);
      if upcase(status) = 'CREATE' then do;
         call send(queue, '_getfield', parms,
            qrc, catname, developer);
         call display("testdata.sapp.addlist.scl",
            catname, developer);
      end;  /* if create */
      else do;
         call send(queue,'_getfield',parms,
         call display("testdata.sapp.addlist.scl",
      end;  /* else update */

      call send(queue,'_recv',qrc);
      put 'Unknown message type: ' msgtype;
      put 'Message discarded.';
   end; /* select */ 

   rc = clearlist(alist);
   rc = clearlist(hlist);
   call send(queue, '_query', eventtype,
      msgtype, hlist, alist,qrc);
end; /* do while */
[1] Create a station for the client.
[2] Access the client's queue.
[3] The OPEN method was successful; are there any messages for the client to fetch?
[4] DELIVERY indicates that the client has messages; stay in the loop as long as messages are found.
[5] Message type (msgtype) 100 means there are new or updated entries.
[6] Check if the status is "create", else it must be "update".
[7] Fetch the next message, if any.

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.