The Triggering sample programs
The function provided in the triggering sample is a subset of that provided in the trigger monitor in the runmqtrm program.
See Features demonstrated in the sample programs on Multiplatforms for the names of these programs.
Design of the triggering sample
The triggering sample program opens the initiation queue using the MQOPEN call with the MQOO_INPUT_AS_Q_DEF option. It gets messages from the initiation queue using the MQGET call with the MQGMO_ACCEPT_TRUNCATED_MSG and MQGMO_WAIT options, specifying an unlimited wait interval. The program clears the MsgId and CorrelId fields before each MQGET call to get messages in sequence.
When it has retrieved a message from the initiation queue, the program tests the message by checking the size of the message to make sure that it is the same size as an MQTM structure. If this test fails, the program displays a warning.
For valid trigger messages, the triggering sample copies data from these fields: ApplicId, EnvrData, Version, and ApplType. The last two of these fields are numeric, so the program creates character replacements to use in an MQTMC2 structure for IBM i, UNIX, Linux, and Windows systems.
The triggering sample issues a start command to the application specified in the ApplicId field of the trigger message, and passes an MQTMC2 or MQTMC (a character version of the trigger message) structure.- In UNIX, Linux, and Windows systems, the EnvData field is used as an extension to the invoking command string.
- In IBM i, it is used as job submission parameters, for example, the job priority or the job description.
Finally, the program closes the initiation queue.
Ending the triggering sample programs on IBM i
A trigger monitor program can be ended by the sysrequest option 2 (ENDRQS) or by inhibiting gets from the trigger queue.
If the sample trigger queue is used, the command is:CHGMQMQ QNAME('SYSTEM.SAMPLE.TRIGGER') MQMNAME GETENBL(*NO)Important: Before starting triggering again on this queue, we must enter the following command:
CHGMQMQ QNAME('SYSTEM.SAMPLE.TRIGGER') GETENBL(*YES)
- Running the Triggering sample programs
This topic contains information about running Triggering sample programs. - Design of the trigger server
The design of the trigger server is similar to that of the trigger monitor, with a few exceptions
Parent topic: Use the sample programs on Multiplatforms