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.
The program takes 2 parameters:
If a queue manager is not specified, it will connect to the default one. A sample initiation queue will have been defined when you ran amqscos0.tst. the name of that queue is SYSTEM.SAMPLE.TRIGGER, and you can use it when you run this program.
This is a trigger monitor for the OS/400 environment. It submits one OS/400 job for each application to be started. This means there is a processing overhead associated with each trigger message.
AMQSTRG4 (in QCSRC) takes two parameters: the name of the initiation queue it is to serve, and the name of the queue manager (optional). AMQSAMP4 (in QCLSRC) defines a sample initiation queue, SYSTEM.SAMPLE.TRIGGER, that you can use when you try the sample programs.
Using the example trigger queue, the command to issue is:
CALL PGM(QMQM/AMQSTRG4) PARM('SYSTEM.SAMPLE.TRIGGER')
Alternatively, you can use the CL equivalent STRMQMTRM - see WebSphere MQ for iSeries V5.3 System Administration.
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:
If either of these tests fail, 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 OS/2, UNIX, and Windows systems, and in an MQTMC structure for OS/400.
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 OS/2, UNIX systems, and Windows systems, the EnvData field is used as an extension to the invoking command string. In OS/400, it is used as job submission parameters, for example, the job priority or the job description. See WebSphere MQ for iSeries V5.3 System Administration for a discussion of job priority and job description.
Finally, the program closes the initiation queue.
This is a trigger server for the OS/400 environment. For each trigger message, this server runs the start command in its own job to start the specified application. The trigger server can call CICS transactions.
AMQSERV4 takes two parameters: the name of the initiation queue it is to serve, and the name of the queue manager (optional). AMQSAMP4 defines a sample initiation queue, SYSTEM.SAMPLE.TRIGGER, that you can use when you try the sample programs.
Using the example trigger queue the command to issue is:
CALL PGM(QMQM/AMQSERV4) PARM('SYSTEM.SAMPLE.TRIGGER')
The design of the trigger server is similar to that of the trigger monitor, except the trigger server:
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)
CHGMQMQ QNAME('SYSTEM.SAMPLE.TRIGGER') GETENBL(*YES)