Question : iSeries - Monitor multiple message queue

I would like to continuously monitor multiple MSGQ's on the iSeries. Specifically I would like to monitor the QSYSOPR and the QSYSMSGQ message queues. I am going to be using the RCVMSG command.  If a message is found, I will send an email with the details and then return to monitoring the queue.

Will I have to have 2 separate CL programs - one for monitoring QSYSOPR and the other for monitoring QSYSMSGQ?  Is it possible to do in one CL?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
MONITOR:                                                              
                                                                      
   RCVMSG     MSGQ(QSYS/QSYSOPR) MSGTYPE(*INQ) WAIT(*MAX) +           
                RMV(*NO) MSG(&BODY1) SECLVL(&BODY2)                   
                                                                      
             SNDDST     TYPE(*LMSG) TOINTNET(([email protected] + 
                          *PRI) ([email protected] *CC)) +           
                          DSTD(&SUBJECT) LONGMSG('Problem: ' *CAT +   
                          ':/N' *CAT &BODY1 *CAT ':/N :/N' *CAT +     
                          'Problem Details:' *CAT ':/N' *CAT +        
                          &BODY2)                                                                       
   GOTO CMDLBL(MONITOR)

Answer : iSeries - Monitor multiple message queue

Max says "block here until a new message is received. "

Fine for processing one queue, but not acceptable for polling multiple queues.

For multiple queues you want to quickly see I there is a message waiting.

Also note that if a message is received on a given queue you might want to loop on that queue until all messages are received rather than polling the next queue.

Do until no more messages
    Receive queue1 wait 0
end
do until no more messages
   Receive q2 wait 0
end
etc
delay
goto top
while msgid <> '  
Random Solutions  
 
programming4us programming4us