IBM MQ Triggering concept

We will see what is IBM MQ Triggering ? How to configure MQ Triggering ? what are the different types of MQ triggering based on the usage ? Steps for configuring MQ triggering ?

Triggering offers us the ability to start some work when some criteria is meet . it save resources like CPU, Memory etc as advantage . Provides flexibility for Administrator to start the channels automatically without manual intervention .

Based on the use of Triggering ,it is basically categorised into two types

  1. Process Triggering
  2. Channel Triggering

Process triggering is something like starting some External application when some criteria is meet external to Queue Manager .

Channel Triggering is just use Trigger data to start the channel instead of external process when the criteria is matches .

Trigger criteria is something like Queue depth reached 100 Messages then some process should start which could be an application that consumes the message in turn or it could be the channel to start which might be inactive from long time waiting for the condition to meet and QMGR send trigger message and place in the initiation queue to start the channel etc .

You have multiple options on the queue for Trigger type .

Trigger on first message- Call a program when depth of queue goes from 0 to 1
Trigger on every message- Call a program for every message entering the queue
Trigger on depth- Call a program when depth of queue gets to a certain number like on 100 messages

Triggering contains

  1. Initiation queue : A special purpose local queue . In simple words its just a local queue to hold trigger events
  2. Application queue : Local queue where the triggering is enabled .
  3. Process definition : it hold the details about the application that will receive the message from application queue
  4. Transmission queue: Transmission queue is required if we want to tigger a channel start .
  5. Trigger event :Trigger event is an event that caused trigger message to be generated when the condition meet
  6. Trigger message : Queue manager create a trigger message when the trigger even occur .it contains the message about the application to start
  7. Trigger monitor : This is a mq program that will monitor initiation queue for the trigger message and start the program

Note:Remember that if you want a trigger to start a channel, you do not need to define a process definition object.

Setup MQ Triggering to Trigger Application

crtmqm QM1

strmqm QM1

runmqsc QM1

define qlocal(QL)

alter qlocal(QL) trigger trigtype(every) initq(IQ) process(PD) # Enable triggering

define ql(IQ)

define process(PD) applicid(‘notepad’) # Create process definition

Start trigger monitor on initiation queue using below command

runmqtrm -q ID -m QM1

Put message in LQ to trigger application .

/usr/mqm/samp/bin/amqsput LQ QM1

Let’s try above and see

 the sequence of events is: 

  1. Sample application amqsput puts a message on the application queue LQ.
  2. The queue manager checks to see if the conditions are met EVERY under which it has to generate a trigger event. They are, and a trigger event is generated. Information held within the associated process definition PD object is used when creating the trigger message.
  3. The queue manager QM1 creates a trigger message and puts it on the initiation queue IQ associated with this application queue LQ, but only if an application (trigger monitor) has the initiation queue open for input.
  4. The trigger monitor retrieves the trigger message from the initiation queue IQ.
  5. The trigger monitor issues a command to start application notepad (the server application).
  6. Instead of notepad you can have another application that can consume the message from LQ and process it .

Setup MQ Triggering to Trigger channel

Instead of using application queue use a local queue as transmission queue and set trigger with process id contains channel name and transmission queue set on the channel

You must specify TRIGGER since the default is NOTRIGGER. Set the trigger type to FIRST

In IBM MQ channel triggering overall we will define three objects and point to each other in a closed loop. The XMITQ points to the PROCESS which points to the CHANNEL which in turn points back to the XMITQ.

First, the XMIT queue must be defined for triggering:

** ————————————–
** Minimal XMITQ definition…
def ql (QMGR.XMITQ1) +
replace +
usage (xmitq) +
** ————————————–
** Added for triggering of channels…
process (QMGR.XMITQ) +
trigger +
trigtype (first)

Secondly define a process definition to point to channel

** ————————————–
** Process definition
** Added for triggering of channels…
def process (QMGR.XMITQ) +
replace +
descr (‘Start Channel when msgs hit XMITQ’) +

** ————————————–
** Minimal Channel definition…
chltype (SDR) +
trptype (TCP) +
xmitq (QMGR.XMITQ) +
mcauser (mqm) +

Start up Default Queue Manager and trigger monitor


#Added for automatic channel initiation

# Queue used must be same as that named in XMITQ definition

Lets try out and see …

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *