Triggering channels

WebSphere® MQ provides a facility for starting an application automatically when certain conditions on a queue are met. This facility is called triggering.

This explanation is intended as an overview of triggering concepts. For a complete description, see Starting WebSphere MQ applications using triggers.

For platform-specific information see the following:
Figure 1. The concepts of triggering
The figure shows the concepts of triggering. The text following this figure explains the objects required and the sequence of events.
The objects required for triggering are shown in Figure 1. It shows the following sequence of events:
  1. The local queue manager places a message from an application or from a message channel agent (MCA) on the transmission queue.
  2. When the triggering conditions are fulfilled, the local queue manager places a trigger message on the initiation queue.
  3. The long-running channel initiator program monitors the initiation queue, and retrieves messages as they arrive.
  4. The channel initiator processes the trigger messages according to information contained in them. This information might include the channel name, in which case the corresponding MCA is started.
  5. The local application or the MCA, having been triggered, retrieves the messages from the transmission queue.
To set up this scenario, you need to:
  • Create the transmission queue with the name of the initiation queue (that is, SYSTEM.CHANNEL.INITQ) in the corresponding attribute.
  • Ensure that the initiation queue (SYSTEM.CHANNEL.INITQ) exists.
  • Ensure that the channel initiator program is available and running. The channel initiator program must be provided with the name of the initiation queue in its start command.
  • Optionally, create the process definition for the triggering, if it does not exist, and ensure that the UserData field contains the name of the channel it serves. Instead of creating a process definition, you can specify the channel name in the TriggerData attribute of the transmission queue. WebSphere MQ for UNIX, Linux and Windows systems, allow the channel name to be specified as blank, in which case the first available channel definition with this transmission queue is used.
  • Ensure that the transmission queue definition contains the name of the process definition to serve it, (if applicable), the initiation queue name, and the triggering characteristics you feel are most suitable. The trigger control attribute allows triggering to be enabled, or not, as necessary.
Note:
  1. The channel initiator program acts as a 'trigger monitor' monitoring the initiation queue used to start channels.
  2. An initiation queue and trigger process can be used to trigger any number of channels.
  3. Any number of initiation queues and trigger processes can be defined.
  4. A trigger type of FIRST is recommended, to avoid flooding the system with channel starts.

Triggering channels on UNIX, Linux and Windows systems.

You can create a process definition in WebSphere MQ, defining processes to be triggered. Use the MQSC command DEFINE PROCESS to create a process definition naming the process to be triggered when messages arrive on a transmission queue. The USERDATA attribute of the process definition contains the name of the channel being served by the transmission queue.

Define the local queue (QM4), specifying that trigger messages are to be written to the initiation queue (IQ) to trigger the application that starts channel (QM3.TO.QM4):

DEFINE QLOCAL(QM4) TRIGGER INITQ(SYSTEM.CHANNEL.INITQ) PROCESS(P1) USAGE(XMITQ)
Define the application (process P1) to be started:

DEFINE PROCESS(P1) USERDATA(QM3.TO.QM4)

Alternatively, for WebSphere MQ for UNIX, Linux and Windows systems, you can eliminate the need for a process definition by specifying the channel name in the TRIGDATA attribute of the transmission queue.

Define the local queue (QM4). Specify that trigger messages are to be written to the default initiation queue SYSTEM.CHANNEL.INITQ, to trigger the application (process P1) that starts channel (QM3.TO.QM4):

DEFINE QLOCAL(QM4) TRIGGER INITQ(SYSTEM.CHANNEL.INITQ) 
USAGE(XMITQ) TRIGDATA(QM3.TO.QM4)

If you do not specify a channel name, the channel initiator searches the channel definition files until it finds a channel that is associated with the named transmission queue.