length msg $ 200;
length arrivet auth size respq sentt 8;
length correlid msgid $ 40;
length label $ 80;
rc=0;
hCursor=0;
transobj=0;
CALL MSMQRECEIVEMSG(hQueue, 0, "RECEIVE", hCursor, transobj, rc,
"ARRIVEDTIME,AUTHENTICATED,BODY_SIZE,CORRELATIONID,
LABEL,MSGID,RESP_QUEUE,SENTTIME",
arrivet, auth, size, correlid, label, msgid, respq, sentt);
if rc ^= 0 then do;
put 'MSMQReceiveMsg: failed';
msg = sysmsg();
put msg;
end;
else do;
put 'MSMQReceiveMsg: succeeded';
/* convert MSMQ arrived time to SAS datetime format */
arrivet = arrivet + 10*365*24*3600 + 3*24*3600 - 5*3600;
put 'arrived time is' arrivet datetime.;
if auth = 1 then put 'message was authenticated';
else put 'message was not authenticated';
put 'message body size is ' size;
put 'correlation id is ' correlid;
put 'label is ' label;
put 'msg id is ' msgid;
put 'resp_queue qid handle is ' respq;
/* convert MSMQ sent time to SAS datetime format */
sentt = sentt + 10*365*24*3600 + 3*24*3600 - 5*3600;
put 'sent time was' sentt datetime.;
end;