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 the following topics for the name of this program on different platforms:
![[Linux]](../common/../develop/nglinux.gif)
Features shown in the C and COBOL MQI samples for AIX® and Linux®
Features shown in the C and COBOL MQI samples for Windows
Features shown in the C, COBOL and RPG MQI samples for IBM® i
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,
AIX, Linux, and Windows systems.
ApplicId field of the trigger message, and passes an MQTMC2 or
MQTMC (a character version of the trigger message) structure.
In AIX, Linux, and Windows systems, the
EnvDatafield 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.
![[IBM i]](ngibmi.gif)
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.
CHGMQMQ QNAME('SYSTEM.SAMPLE.TRIGGER') MQMNAME GETENBL(*NO)
CHGMQMQ QNAME('SYSTEM.SAMPLE.TRIGGER') GETENBL(*YES)