IBM MQ can start applications automatically when messages arrive on a queue—triggering. The trigger type (TRIGTYPE on the queue definition) decides the rule: start when the first message lands, start for every message, or start when depth crosses a threshold. Choosing the wrong type causes missed processing (FIRST when multiple parallel consumers are needed without depth scaling) or process storms (EVERY under high put rate). Beginners copy TRIGGER(YES) from samples without understanding TRIGTYPE; operations then wonders why fifty Java processes spawned overnight. This tutorial compares FIRST, EVERY, and DEPTH trigger types, explains TRIGDPTH and TRIGDATA, relates types to initiation queues and PROCESS objects, and gives selection guidance for batch, interactive, and scale-out workloads.
An application puts to QLOCAL WORK.IN with TRIGGER(YES). When trigger conditions match TRIGTYPE, the queue manager writes a trigger message to the initiation queue (often SYSTEM.DEFAULT.INITIATION.QUEUE or a dedicated QLOCAL). The trigger monitor reads that message and starts the program named in the PROCESS object (APPLICID, USERDATA). The started program opens WORK.IN and gets messages. Trigger type controls how often that chain fires—not how the application processes messages once running.
| TRIGTYPE | Fires when | Best for |
|---|---|---|
| FIRST | First message after queue was empty | Single consumer per idle-to-busy cycle |
| EVERY | Each message put (per rules) | Low volume, strict per-message start |
| DEPTH | CURDEPTH >= TRIGDPTH | Scale extra workers when backlog grows |
FIRST is the default pattern for many enterprise batch triggers. When CURDEPTH was zero and a put makes depth one, MQ generates a trigger message. While the queue stays non-empty, additional puts do not generate more FIRST triggers—the assumption is the already-started consumer will drain the queue. If the consumer dies with messages remaining, depth is still non-zero so FIRST may not fire again until the queue empties. Operations must monitor consumer health or use DEPTH for scaling. See our first-trigger tutorial for operational detail.
EVERY attempts to trigger for each message arrival (subject to queue manager coalescing and trigger monitor capacity). At hundreds of messages per second, starting one OS process per message exhausts CPU and file descriptors. Use EVERY only when volume is low and each message truly requires an isolated short-lived process—rare in modern MQ estates. Prefer FIRST with a long-running consumer or DEPTH with controlled parallelism.
DEPTH compares CURDEPTH to TRIGDPTH. Example: TRIGDPTH(100) starts additional consumers when backlog reaches one hundred messages—useful when message size or processing time varies and you want more workers only under load. Set TRIGDPTH high enough to avoid flapping triggers at boundary. Combine with application design that exits when the queue is empty so you do not accumulate idle processes.
12345DEFINE QLOCAL('WORK.IN') TRIGGER(YES) TRIGTYPE(FIRST) + PROCESS('WORK.PROC') INITQ('SYSTEM.DEFAULT.INITIATION.QUEUE') DEFINE QLOCAL('WORK.BULK') TRIGGER(YES) TRIGTYPE(DEPTH) TRIGDPTH(500) + PROCESS('WORK.PROC') INITQ('INITQ.BACKLOG') DEFINE PROCESS('WORK.PROC') APPLICID('/opt/app/consume.sh') USERDATA('pool=1')
TRIGDATA on the queue passes a string to the trigger message so one PROCESS definition can serve multiple queues with different parameters (queue name, thread pool id). PROCESS APPLICID is the executable or script; USERDATA is often copied into the environment. Wrong PROCESS name leaves messages on the application queue with trigger messages piling on the initiation queue—check AMQERR for trigger monitor errors.
FIRST is a doorbell when the first package arrives—one ring starts the handler. EVERY rings the bell for every package—noisy. DEPTH sounds an alarm when the pile reaches a line on the wall—call more helpers.
When mail arrives in the box, you can ring once for the first letter (FIRST), ring for every single letter (EVERY), or ring when the box is so full you need more friends to help (DEPTH).
Define two queues on lab QM: FIRST vs DEPTH; put messages and observe initiation queue depth.
Calculate safe TRIGDPTH if each message takes 2 seconds and you want max 5 parallel workers.
Explain why EVERY is risky at 1000 msg/sec in one paragraph.
1. TRIGTYPE(FIRST) fires when:
2. TRIGTYPE(DEPTH) uses:
3. TRIGTYPE(EVERY) can cause:
4. Trigger messages go to: