Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run a program after receiving a message in MSGQ ?

Status
Not open for further replies.

francoisf

Programmer
Feb 11, 2004
30
0
0
FR
Hi,

i want a program to be run (immediatly and automatically) when a message arrives in a MSGQ.

I tried this :

CRTMSGQ MSGQ(MYLIB/MYMSGQ)
CHGMSGQ MSGQ(MYLIB/MYMSGQ) DLVRY(*BREAK) PGM(MYLIB/MYPGM)

but it doesn't work : the program is not called.

Thank if you can help !
 
francoisf,
Just create a message queue and submit a CL program that runs continuously for the program to wait indefinitely for an incoming message.
e.g.
Code:
...
Loop:
Rcvmsg msgq(MYLIB/MYMSGQ) wait(*MAX) rmv(*YES) msg(&MSG) +
msgdta(&MSGDTA) msgid(&MSGID)
If (&MSGID *EQ 'AAAnnnn') CALL MYLIB/MYPGM ...
If (&MSG = 'STOP') RETURN /* End */
GoTo Loop
...
When any message arrives in MYLIB/MYMSGQ, the cl continues sequentially after the RCVMSG command.
if the retrieved &MSGID variable equals to 'AAAnnnn" MYLIB/MYPGM program is fired, though you could suppress the condition.
If the retrieved &MSG variable equals to STOP, the program ends.

HTH
 
I believe there is also an API if you would rather have it written in RPG, but TalkTurkey's idea is easy.

iSeriesCodePoet
iSeries Programmer/Lawson Software Administrator
[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top