TS/MP Pathsend and Server Programming Manual (G06.24+, H06.03+)

Examples
NonStop TS/MP Pathsend and Server Programming Manual132500
B-50
Pathsend Requester Example
?PAGE "THE BREQ PROGRAM'S MAIN PROCEDURE"
! This procedure calls the initialize routine to start up, sets up a
! memory pool, and loops reading the IN file.
! Input records are validated, control blocks are allocated, the
! transaction is initiated and then completed, and control blocks
! are de-allocated.
! If we fail to execute the transaction and the error is retryable,
! we retry it MAX-RETRIES times, where MAX-RETRIES is a param msg
! defined at the TACL prompt.
PROC breq^program MAIN;
BEGIN
STRUCT .input^buf (breq^input^rec^template); ! buf to hold input record
INT .EXT cb^list^head (control^block^template) := nil^addr;
!first cb in linked list.
INT error := 0; ! used with read of input file
INT record^number := 0; ! input file record number we're processing
INT retry^count; ! # times we retried transaction a failure
LIT global^msg^len = $OCCURS(breq^output^rec^template.non^send^error^msg);
! len of non-Pathsend error msg buffer
CALL initialize;
! Define the memory pool that we use to store the control blocks
! (cb's), maintained as a linked list in the upper 32K. Cb's are
! allocated when we process one transaction, and are deallocated
! when we complete one transaction. A transaction is driven by data
! in one record of the input file.
CALL create^the^memory^pool;
! Loop until end of IN file, reading one record and doing the
! transaction associated with that record. A transaction is two
! Pathsend sends and one WRITE to the message log file.
WHILE NOT error DO
BEGIN
input^buf ':=' " " & input^buf FOR (($LEN (input^buf) + 1) / 2) - 1;
global^non^pathsend^error^msg ':=' global^msg^len * [" "];
IF read^ (in^fnum, input^buf, $LEN (input^buf), error)
THEN ! successfully read 1 record
BEGIN
! Record^Number is the input file record number we're
! processing, and is used in the output to associate the
! outcome of a transaction with the record used to generate
! the transaction.
record^number := record^number + 1;
! Tracing is enabled by specifying a trace file ASSIGN. If
! enabled, a trace record is written to the trace file when
! this program performs certain actions. For example, reading
! an input record, and starting or aborting a transaction.
CALL write^trace^file (trace^write^blank^line);
CALL write^trace^file (trace^read^input, record^number);
! Besides validating the input record, the validate routine
! looks up ASSIGN names for PATHMON system and process names