Link to home
Start Free TrialLog in
Avatar of Matthew Roessner
Matthew Roessner

asked on

Monitor QSYSOPR MSGQ

I would like to write a CL program that will monitor the QSYSOPR MSGQ for inquiry messages (messages needing a response).  If it finds one, I would like to send an email (SNDDST) with the 'Message' (Message 'LBE9001' in called program '$CBLDUMP' (C D F G).) is the Subject and the 'Cause' is the body of the email.

Does anyone know a good/easy way to do this?

I appreciate your help.
Avatar of Barry Harper
Barry Harper
Flag of Canada image


Generic logic goes like this:

Use the RCVMSG command to receive the messages from the QSYSOPR message queue.
If the return type is '05', then it is an inquiry message that you want to process.
Loop back to receive more messages

If you need more detailed example, let me know!
Barry
Avatar of Matthew Roessner
Matthew Roessner

ASKER

I was starting with something like what I have laid out below.

Essentially I want to monitor the QSYSOPR message queue for any messages needing a reply. If it finds one, I want to email our datacenter. I want the subject of the email to be the Message (as indicated in my post) and the Body of the email to be the Cause of the message (typically when you do a F1).  After the email is sent, I want to continue to monitor for INQ messages...

I am not sure which indentifier to use within the RCVMSG command for those variables.  

Also, I know the variables have to be of the correct type. I just guessed with CHAR...

Will the code below get me to where I need to be? Obviously I need to add the &SUBJECT and &BODY into the RCVMSG command somewhere.

Thanks Barry...
PGM                                             
                                                
/*DECLARE VARIABLES */                          
         DCL  &SUBJECT        *CHAR     120     
         DCL  &BODY           *CHAR     7500    

MONITOR:                                                             
                                                                     
            RCVMSG     MSGQ(QSYS/QSYSOPR) MSGTYPE(*INQ) WAIT(*MAX) +                      RMV(*NO)                                    
                                                                 
            SNDDST     TYPE(*LMSG) TOINTNET((email@test.com)) +  
                         DSTD(&SUBJECT) LONGMSG(&BODY) +             
                       USRID(SERVER AS400)                         
                                                                     
         GOTO CMDLBL(MONITOR)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Barry Harper
Barry Harper
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Does the MSGTYPE of *INQ not filter out all the messages appropriately?

Thanks for the information.  I am not sure of the impact, but I was hoping to just let this program run all the time to always be monitoring the QSYSOPR MSGQ so that any time a message would come in....it would send the email to our Datacenter.  In that case...it would not end unless we would be doing an IPL...
Sorry, I overlooked that. You may want to receive all messages in your program because there may be important, non-inquiry messages that you decide to email out as well.
Thanks for the help Barry. You definitely helped out and answered all my questions