The system provides a watch-for-event function that allows you to watch for messages.
The watch-for-event function allows you
to specify messages for which you want the system to watch. When these
messages occur, a user exit program is called to take any necessary
action. You must specify the message queue or job log where you expect
the message to be sent. You can specify some text string to be compared
against the message data, the from-program, or the to-program. You
can also select watches by message type or severity. Using this watch
selection capability allows you to be informed of only certain messages. 
Use the Start Watch (STRWCH) command
to start a watch session and be notified when a specified message
occurs. When the watched-for message is added to the specified message
queue or log, the watch exit program is called. The watch exit program
runs in a job in the QUSRWRK subsystem.
The Work
with Watches (WRKWCH) command can be used to show a panel
with the list of active watches on the system. The End Watch
(ENDWCH) command can be used to end watch sessions. 
The Start Watch (QSCSWCH) and End Watch (QSCEWCH) APIs have a similar usage to the STRWCH and ENDWCH commands.
The Retrieve Watch Information (QSCRWCHI) and Retrieve
Watch List (QSCRWCHL) APIs can be used to obtain information
about watches.
The watch for event function is also incorporated into some trace commands:
Watch support enhances the trace functions
by automatically monitoring and ending traces when certain predetermined
criteria are met. Using watch support can prevent the loss of valuable
trace data and reduce the amount of time you need to spend monitoring
traces. 