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
- Process Triggering
- 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
- Initiation queue : A special purpose local queue . In simple words its just a local queue to hold trigger events
- Application queue : Local queue where the triggering is enabled .
- Process definition : it hold the details about the application that will receive the message from application queue
- Transmission queue: Transmission queue is required if we want to tigger a channel start .
- Trigger event :Trigger event is an event that caused trigger message to be generated when the condition meet
- Trigger message : Queue manager create a trigger message when the trigger even occur .it contains the message about the application to start
- 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
alter qlocal(QL) trigger trigtype(every) initq(IQ) process(PD) # Enable triggering
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:
- Sample application amqsput puts a message on the application queue LQ.
- 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.
- 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.
- The trigger monitor retrieves the trigger message from the initiation queue IQ.
- The trigger monitor issues a command to start application notepad (the server application).
- 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) +
usage (xmitq) +
** Added for triggering of channels…
initq (SYSTEM.CHANNEL.INITQ) +
process (QMGR.XMITQ) +
Secondly define a process definition to point to channel
** Process definition
** Added for triggering of channels…
def process (QMGR.XMITQ) +
descr (‘Start Channel when msgs hit XMITQ’) +
** Minimal Channel definition…
def chl (QMGR.CHANNEL.NAME) +
chltype (SDR) +
trptype (TCP) +
conname (‘MACHINE.NAME.OR.IP.ADDRESS’) +
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
runmqchi -q SYSTEM.CHANNEL.INITQ
Lets try out and see …