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 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 [IBMi] 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. [IBMi]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.

[IBMi]

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)
Note: Before starting triggering again on this queue, you must enter the command:

CHGMQMQ QNAME('SYSTEM.SAMPLE.TRIGGER') GETENBL(*YES)