[IBM i]

Using triggering with the Request RPG sample for IBM® i

To run the sample using triggering, start the trigger server program, AMQ3SRV4, against the required initiation queue in one job, then start AMQ3REQ4 in another job.

This means that the trigger server is ready when the Request sample program sends a message.
Note:
  1. The samples use the SYSTEM SAMPLE TRIGGER queue as the initiation queue for SYSTEM.SAMPLE.ECHO, SYSTEM.SAMPLE.INQ, or SYSTEM.SAMPLE.SET local queues. Alternatively, you can define your own initiation queue.
  2. The sample definitions created by the AMQSAMP4 program cause the C version of the sample to be triggered. If you want to trigger the RPG version, you must change the process definitions SYSTEM.SAMPLE.ECHOPROCESS and SYSTEM.SAMPLE.INQPROCESS and SYSTEM.SAMPLE.SETPROCESS. You can use the CHGMQMPRC command (see Change MQ Process (CHGMQMPRC) for more details) to do this, or edit and run your own version of AMQSAMP4.
  3. You must compile the trigger server program from the source provided in QMQMSAMP/QRPGLESRC.
Depending on the trigger process you want to run, AMQ3REQ4 should be called with the parameter specifying request messages to be placed on one of these sample server queues:
  • SYSTEM.SAMPLE.ECHO (for the Echo sample programs)
  • SYSTEM.SAMPLE.INQ (for the Inquire sample programs)
  • SYSTEM.SAMPLE.SET (for the Set sample programs)
A flow chart for the SYSTEM.SAMPLE.ECHO program is shown in Figure 1. Using the example the command to issue the RPG program request to this server is:
   CALL PGM(QMQMSAMP/AMQ3REQ4) PARM('SYSTEM.SAMPLE.ECHO
   + 30 blank characters','Queue_Manager_Name')

because the queue name and queue manager name must be 48 characters in length.

Note: This sample queue has a trigger type of FIRST, so if there are already messages on the queue before you run the Request sample, server applications are not triggered by the messages you send.
If you want to attempt further examples, you can try the following variations:
  • Use AMQ3TRG4 instead of AMQ3SRV4 to submit the job instead, but potential job submission delays could make it less easy to follow what is happening.
  • Use the SYSTEM.SAMPLE.INQ and SYSTEM.SAMPLE.SET sample queues. Using the example data file, the commands to issue the RPG program requests to these servers are:
       CALL PGM(QMQMSAMP/AMQ3INQ4) PARM('SYSTEM.SAMPLE.INQ
       + 31 blank characters')
       CALL PGM(QMQMSAMP/AMQ3SET4) PARM('SYSTEM.SAMPLE.SET
       + 31 blank characters')
    

    because the queue name must be 48 characters in length.

    These sample queues also have a trigger type of FIRST.