Scenario: Use watch support with a job trace

You can use watch support with a job trace.

Assume that you write a sockets server application that occasionally fails. When the application fails, the TCP3B04 socket API error is sent to the job log.

To solve the problem, you need to perform a job trace using watch support so that the trace is automatically stopped when the TCP3B04 error is sent to the job log. This allows you to capture only the data that you need to analyze the problem and prevents the trace from running longer than necessary.

To perform the job trace using watch support, follow these steps:

  1. Start the job trace:
    1. At the command line, type STRTRC and press F4.
    2. For the Session ID prompt, specify a meaningful session identifier, such as mytrace.
    3. For the Jobs parameter, specify these values:
      • For the Jobs, Job Name prompt, type the job name, such as SOCKETAPP.
      • For the Jobs, User prompt, specify the user ID, such as user.
      • For the Jobs, Number prompt, type *ALL.
    4. For the Watch for message, Message identifier prompt, type TCP3B04.
    5. For the Watched message queue, Message queue prompt, type *JOBLOG. This ensures that the communications trace stops running when the TCP3B04 message is sent to the job log.
    6. For the Watched job parameter, specify these values:
      • For the Jobs, Job Name prompt, type SOCKETAPP.
      • For the Jobs, User prompt, specify the user ID, such as user.
      • For the Jobs, Number prompt, type *ALL.
  2. Verify that the watch support started:
    1. At the command line, type DSPLOG and press F4.
    2. For the Log prompt, type QHST. You should see the following message:

      Job jobnumber/user/QSCSTTxxxx started on mm/dd/yy at hh:mm:ss in subsystem QUSRWRK in QSYS. Job entered system on mm/dd/yy at hh:mm:ss

      where user is the name of the user that runs the STRTRC command and where xxxx indicates a unique identifier for the watch job. Note that STT in the middle of the job name indicates that the watch job was started by the STRTRC command.
  3. Verify that the watch support is running:
    • At the command line, type WRKACTJOB SBS(QUSRWRK).
    • You should see the watch job running in the QUSRWRK subsystem. The job is usually in DEQW status if the watched message has not been sent.
  4. After the TCP3B04 message is sent to the jobnumber/user/SOCKETAPP job log, you should verify that the trace has ended:
    • At the command line, type DSPMSG MSGQ(*SYSOPR).
    • You should see the CPI3999 message which indicates that the STRTRC command was ended because of reason code 02. Reason code 02 indicates that Watch for event criteria met because of message id TCP3B04 found in jobnumber/user/SOCKETAPP.
  5. Format the trace output using the Print Trace (PRTTRC) command to analyze the data you collected.