The following program
runs on the Windows XP machine and requests a data set:
data _null_;
length msg $ 200;
length qid2 tid rc 8;
length map $80;
length recv1 $50;
length event $10;
length rpname $256;
length type $8;
length qual1 qual2 $40;
libname out '.';
tid=0;
rc=0;
put '----';
put 'Call INIT';
CALL INIT(tid, 'MQSERIES', rc);
if rc ^= 0 then do;
put 'INIT: failed';
msg = sysmsg();
put msg;
end;
else put 'INIT: succeeded';
rc=0;
qid=0;
put '----';
put 'Call OPENQUEUE to open the response queue';
CALL OPENQUEUE(qid, tid, 'XPQMGR:REPLY', 'fetch',
rc, "POLL(TIMEOUT=20)");
if rc ^= 0 then do;
put 'OPENQUEUE: failed';
msg = sysmsg();
put msg;
end;
else put 'OPENQUEUE: succeeded';
rc=0;
qid2=0;
put 'Call OPENQUEUE to open the request queue on qid2';
CALL OPENQUEUE(qid2, tid, 'XPQMGR:AIX.TRIGQUEUE',
'DELIVERY', rc, "POLL(Timeout=15)");
if rc ^= 0 then do;
put 'OPENQUEUE: failed';
msg = sysmsg();
put msg;
end;
else put 'OPENQUEUE: succeeded';
rc=0;
put '----';
put 'Call SETMAP';
CALL SETMAP('mqclientmap', 'REGISTRY', rc, 'CHAR,,50');
if rc ^= 0 then do;
put 'SETMAP: failed';
msg = sysmsg();
put msg;
end;
else put 'SETMAP: succeeded';
parm1="calories";
put '---- Send a message to the request queue qid
requesting the specified data set -----';
put 'Call SENDMESSAGE';
call sendmessage(qid2,rc,"map, respqueue",
"mqclientmap","R64:D8650",parm1);
if rc ^= 0 then do;
put 'send message failed: ';
msg=sysmsg();
put msg;
end;
else put 'send message succeeded';
slept = sleep(1);
rc = 0;
put '---- receive a data set from the reply queue ----';
put 'Call RECEIVEMESSAGE';
map = "mqclientmap";
call receivemessage(qid, rc, event,
attchflg,"map", map, recv1);
put 'response queue =' rpname;
put 'qid =' qid;
put 'event = ' event;
put 'attchflg =' attchflg;
if rc ^= 0 then do;
put 'receive message failed: ';
msg=sysmsg();
put msg;
end;
else do;
put 'receive message succeeded';
put "map =" map;
put "recv1 =" recv1;
end;
if event eq 'DELIVERY' then
do;
put 'Message has been delivered';
if attchflg = 1 then
do;
put '---- check for attachments ----';
call getattachment(qid, lastflag, attachid,
type, qual1, qual2, rc);
if rc ^= 0 then do;
put 'get attachment failed: ';
msg=sysmsg();
put msg;
end;
else put 'get attachment succeeded';
if type="DATASET" then
do;
put '--- accept attachment into a data set ---';
put "qual2 = " qual2;
call acceptattachment(qid, attachid,
"out", qual2, rc);
if rc ^= 0 then do;
put 'accept DATASET failed: ';
msg=sysmsg();
put msg;
end;
else put 'accept DATASET succeeded';
end;
end;
end;
rc=0;
put '----';
put 'Call CLOSEQUEUE for queue1';
CALL CLOSEQUEUE(qid, rc);
if rc ^= 0 then do;
put 'CLOSEQUEUE: failed';
msg = sysmsg();
put msg;
end;
else put 'CLOSEQUEUE: succeeded';
rc=0;
put '----';
put 'Call CLOSEQUEUE for queue2';
CALL CLOSEQUEUE(qid2, rc);
if rc ^= 0 then do;
put 'CLOSEQUEUE: failed';
msg = sysmsg();
put msg;
end;
else put 'CLOSEQUEUE: succeeded';
rc=0;
put '----';
put 'Call TERM';
CALL TERM(tid, rc);
if rc ^= 0 then do;
put 'TERM: failed';
msg = sysmsg();
put msg;
end;
else put 'TERM: succeeded';
run;