70 pts.
 AS/400 message queue
Hi dear All,

I'm stuck up.. in my first message queue program.

I read message on the *msgq (using RCVMSG) and write it in a PF.

I've 2 (dumb) Questions.

1. I provide 'message queue' as a parameter to RCVMSG command. when the command is executed, it reads only one row at a time. so If I've 15 rows of messages on a queue, I execute RCVMSG in a loop and save messages one by one. Is this the correct approach?

2. Once I'm done executing this program, IF I again call the same program RCVMSG doesnt read anything from the message Q (I dont remove messages in RCVMSG). this directs me to the thought that, any message queue can be read only once even if I dont remove any message from the Q. Is this true? if yes then what if I need to execute this program more than once due to some failures/exceptions

Command I use

RCVMSG     MSGQ(&EMSGQ) RMV(*NO) MSG(&FSTLVL) +                   SECLVL(&SNDLVL)     

 

This is what the message queue contains -

Company Code Required                                                 Enter Account Code                                                    Product Deduction Group 001 has been copied to Deduction Group 001.   Product Coverage not found.                                           Errors occurred while processing GGI Component 75016 19.              Errors occurred while processing Transaction Component '75016' '19'.  Errors occurred while processing GGI Transaction 75016.              



Software/Hardware used:
AS400/ RPG/CL
ASKED: June 17, 2010  1:29 PM
UPDATED: June 17, 2010  6:08 PM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

First, unless you maintain strict control over what messages may be sent to your message queue, it doesn’t make much sense to “write it in a PF”. A PF isn’t very well suited for many messages.

Second, yes, RCVMSG will return one message at a time. If you need to collect sets of messages, use the List Nonprogram Messages (QMHLSTM) API and process each set before requesting the next.

Third, to handle old messages with RCVMSG, review the PGM() and RESET() parameters of the CHGMSGQ command. In particular, note the {help} text reference to message keys. You can receive any message if you know its message key.

Tom

 110,115 pts.