Watch for messages

The system provides a watch for event function which allows you to watch for messages.

The watch for event function allows you to specify messages for which you want the system to watch. Once these messages occur, a user exit program will be 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 in order 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. Every time a watch session is started a job is submitted into QUSRWRK subsystem with the same name as the session id. This is where the watch exit program runs.

The Work with Watches (WRKWCH) command can be used to show a panel with the list of active watches on the system, while End Watch (ENDWCH) command can be used to end a watch session.

The Start Watch (QSCSWCH) and End Watch (QSCEWCH) APIs have a very similar usage to the STRWCH and ENDWCH commands.

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. This prevents the loss of valuable trace data and reduces the amount of time you need to spend monitoring traces.

Related information
Watch for event function
Monitoring APIs