WebSphere® Support Technical Exchange
WebSphere MQ Triggering
Beverly Brown, Calista Stevens
Agenda
What is triggering
How does triggering work
The flow of triggering
The different types of triggering
How to set up triggering
The conditions for a trigger event
How to diagnose triggering problems
Miscellaneous notes
Acknowledgement
Special thanks to Calista Stevens for her
Triggering – What is it?
WebSphere MQ provides a feature that enables an
application or channel to be started automatically when there are messages available to retrieve from a queue.
Triggering - How does it work?
A message is put to a queue defined as triggered. If a series of conditions are met, the queue
manager sends a trigger message to an initiation queue. This is called a trigger event.
A trigger monitor reads the trigger message and takes the appropriate action based on the contents of the message, which is typically to start a program to process the triggered queue.
Trigger monitors may be built-in, supplied by a SupportPac, or user written.
Flow of Triggering
Application Queue Manager
INITIATION QUEUE
User application started by trigger monitor or MCA started by channel initiator Program Application Xmitq or Localq Local or MCA
1.Put Message To Queue
2.Trigger Message Sent
5.Message Retrieved from local or xmit queue
TRIGTYPE
FIRST: A trigger event occurs when the current
depth of the triggered queue changes from 0 to 1. Use this type of trigger when the serving program will process all the messages on the queue (i.e. until MQRC_NO_MSG_AVAILABLE).
EVERY: A trigger event occurs every time a
message arrives on the triggered queue. Use this type of trigger when the serving program will only process one message at a time.
TRIGTYPE
DEPTH: A trigger event occurs when the number of
messages on the triggered queue reaches the value of the TRIGDPTH attribute. Use this type of trigger when the serving program is designed to process a fixed number of messages (i.e. all replies for a
certain request).
Note: When triggering by depth, triggering is
disabled and must be re-enabled by using MQSET or ALTER QLOCAL.
Trigger Interval
TriggerInterval or TRIGINT is a time interval
specified on the QMGR definition for use by queues defined as TRIGTYPE=FIRST.
Situations may occur when messages are left on the queue. New messages will not cause another trigger message. To help with this situation, a
trigger message will be created when the next
message is put if TriggerInterval has elapsed since the last trigger message was created for the queue. z/OS has a “backstop” process to scan queues.
Channel Triggering Setup
Create an initiation queue (non-z/OS platforms) or use the default SYSTEM.CHANNEL.INITQ.
Create a process definition (optional).
TriggerData may be specified in lieu of a process
definition.
Create or alter a transmission queue.
Associate the initiation queue and the process definition (if applicable) with the transmission queue, and specify the trigger attributes.
Channel Triggering Setup Example 1
DEFINE QLOCAL(QM2) REPLACE + USAGE
(XMITQ) TRIGGER TRIGTYPE(FIRST) + TRIGDATA(QM1.TO.QM2) + INITQ
(SYSTEM.CHANNEL.INITQ)
QM2 is the name of the XMITQ
QM1.TO.QM2 is the name of the channel to be
started when a message hits the XMITQ
SYSTEM.CHANNEL.INITQ is the initq monitored by
Channel Triggering Setup Example 2 - dist
DEFINE QLOCAL(QM4) TRIGGER +
INITQ(SYSTEM.CHANNEL.INITQ) + PROCESS(P1) USAGE (XMITQ)
DEFINE PROCESS(P1) +
USERDATA(QM3.TO.QM4)
The XMITQ definition has PROCESS instead of
TRIGDATA
Channel Triggering Setup Example 3 -- z/OS
DEFINE QLOCAL(QM4) TRIGGER +
INITQ(SYSTEM.CHANNEL.INITQ) + PROCESS(P1) USAGE (XMITQ)
DEFINE PROCESS(P1) APPLTYPE(MVS) +
APPLICID(‘CSQX START’) + USERDATA(QM3.TO.QM4)
Quotes for APPLICID are not needed on
CSQOREXX panels
Channel Triggering Setup Example 4 – i5/OS
CRTMQMQ QNAME(initq_name)
CRTMQMPRC PRCNAME(proc_name) USRDATA
(chlname) APPID(QMQM/RUNMQCHL)
CRTMQMQ QNAME(xmitq_name) PRCNAME
(proc_name) TRGENBL(*YES) TRGTYPE(*FIRST) INITQNAME(initq_name) USAGE(*TMQ)
Application Triggering Setup
Create an initiation queue or use the default SYSTEM.DEFAULT.INITIATION.QUEUE.
Create a process definition.
Create or alter a local or model queue.
Associate the initiation queue and process definition with the local queue, and specify the trigger
Application Triggering Setup -PROCESS
APPLICID is the name of the application executable
file, e.g.
- For APPLTYPE(UNIX):
APPLICID ('/u/admin/test/IRMP01') - For APPLTYPE(WINDOWSNT):
APPLICID(‘c:\appl\test\irmp01.exe.’)
On UNIX® systems, ENVRDATA can be set to the
ampersand character to make the started application run in the background.
Application Triggering Setup Example 1
DEFINE QLOCAL (‘IQ’) REPLACE
DEFINE PROCESS (PROC) REPLACE +
APPLTYPE ('CICS') APPLICID ('PAYR') + USERDATA ('Payroll data')
DEFINE QLOCAL (Q1) REPLACE +
INITQ (‘IQ’) PROCESS (‘PROC’) + TRIGGER TRIGTYPE (FIRST)
Note: If using TRIGTYPE(DEPTH) then
Application Triggering Setup Example 2
CRTMQMQ QNAME(initq_name)
CRTMQMPRC PRCNAME(proc_name) APPID(lib/
pgm) ENVDATA (‘JOBNAME(trigapl) JOBD(lib/ jobd)’)
CRTMQMQ QNAME(lclq_name) PRCNAME
(proc_name) TRGENBL(*YES) TRGTYPE(*FIRST) INITQNAME(initq_name)
Note: If using TRGTYPE(*DEPTH) then
Trigger conditions
A trigger message is sent to the initiation queue when all of the following conditions are satisfied: 1. A message is put on a transmission or local
queue.
2. The message’s priority is greater than or equal to the TriggerMsgPriority of the queue.
Trigger conditions
3. The number of messages on queue was previously
- Zero for trigger type FIRST
- Any number for trigger type EVERY or *ALL - TriggerDepth minus 1 for trigger type DEPTH 4. For trigger type FIRST or DEPTH, no program
has the trigger queue open for GETs (Open input count=0).
5. The Get enabled attribute is set to YES on the triggered queue.
Trigger conditions
6. A Process name is specified and exists, or for transmission queues, TriggerData contains the name of a channel.
7. An Initiation queue is specified and exists and GETs and PUTs are enabled for the initiation queue.
8. The trigger monitor has been started and has the initiation queue open for GETs
Trigger conditions
9. The TriggerControl attribute is set to YES on the triggered queue.
10. The TriggerType attribute is not set to NONE. 11. For Trigger Type FIRST, the queue was not
previously empty, but the TriggerInterval set for the QMGR has elapsed.
12. The only application serving the queue issues MQCLOSE and there are still messages on the
Trigger conditions
13. Certain trigger attributes of the triggered queue are changed, such as
- NOTRIGGER to TRIGGER
- PUT or GET DISABLED to ENABLED
or a trigger monitor opens the Initiation queue. 14. MSGDLVSQ is set correctly relative to the
priority of the messages and the TriggerMsgPriority setting.
Problem Determination
If the setup is brand new or any configuration
changes have been made, verify all the definitions are complete and correct.
If the setup is brand new or has worked before, verify all the conditions for a trigger event are satisfied.
If channel triggering, verify the correct channel name is specified and the channel is not in a STOPPED state.
Problem Determination
If application triggering- verify the application name is correct and exists - verify the application is coded correctly
- verify the correct authorizations are in place. Verify a trigger message can be delivered.
Verify a trigger monitor is active.
Verify trigger type and application design match. Try manually starting the triggered application to
Problem Determination
Stranded messages may occur when the triggered
application fails to remove one or more messages - for TriggerType FIRST, use TriggerInteval as a “safety net”, because a trigger event only occurs when depth goes from 0 to 1.
- for TriggerType EVERY, if the triggered application only does one MQGET, manual intervention will be required to process the messages. Otherwise, the application will only read the oldest message on the next successful trigger and the queue depth will
Problem Determination
If there is a loop or high CPU:
- Change the triggered application to specify a
WaitInterval on its MQGET. Remember Condition 12 and see “Getting messages from a triggered queue”:
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/ com.ibm.mq.csqzal.doc/fg13940_.htm- Check the
BackoutCount in the MQMD
Search the Support web page at
http://www-01.ibm.com/software/integration/wmq/support/
Notes:
For trigger EVERY, if the trigger monitor ends
prematurely, no matter how many messages reside on the queue only one trigger message will be
created on restart.
RUNMQTRM will not get another trigger message
until the application completes. To prevent trigger messages from accumulating
- Run multiple trigger monitors or
Notes:
A trigger message is put to the dead letter queue when
- The queue manager can not put a trigger message on the INITQ
- RUNMQTRM detects an error in the trigger message structure
- RUNMQTRM detects an unsupported application type
- RUNMQTRM can not start the application
- RUNMQTRM detects a data conversion error
Notes:
Trigger messages are non-persistent.
Conditions for a trigger event are “persistent”, so, if a trigger message is lost a trigger message will be created when the conditions are met.
Trigger messages take on the default priority of the INITQ.
Trigger monitors can not retrieve messages that are part of a unit of work until the unit of work completes (applies whether it is committed or
Notes:
The queue manager counts both committed and
uncommitted messages on the trigger queue when assessing the conditions for a trigger event.
The exception is that only committed messages cause a trigger event for shared queues (on a Coupling Facility) on z/OS.
After recycling the queue manager or trigger
monitor, a trigger message may be created if the triggered queue has messages on it and provided the trigger conditions are met.
Notes:
When triggering channels, trigger type FIRST or DEPTH is recommended.
Disabling triggering is not under syncpoint control so triggering can not be re-enabled by backing out a unit of work. If a program backs out a unit of work or abends, triggering for DEPTH must be re-enabled by MQSET, ALTER or CHGMQMQ.
On z/OS, the CICS trigger monitor
Triggering Documentation and SupportPacs
Channel Triggering: WebSphere MQ
Intercommunication Guide, Chapter 2
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/ com.ibm.mq.csqzae.doc/ic10580_.htm
Application Triggering: WebSphere MQ Application Programming Guide, Chapter 14
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/ com.ibm.mq.csqzal.doc/fg13830_.htm Link to manuals: http://www-01.ibm.com/software/integration/wmq/library/ MQ SupportPacs: http://www-01.ibm.com/support/docview.wss?
Summary
What is triggering and how does it work How to set up triggering
The conditions for a trigger event
Additional WebSphere Product Resources
Discover the latest trends in WebSphere Technology and implementation, participate in technically-focused briefings, webcasts and podcasts at: http://www.ibm.com/
developerworks/websphere/community/
Learn about other upcoming webcasts, conferences and events: http://www.ibm.com/ software/websphere/events_1.html
Join the Global WebSphere User Group Community: http://www.websphere.org
Access key product show-me demos and tutorials by visiting IBM® Education Assistant:
http://www.ibm.com/software/info/education/assistant
View a Flash replay with step-by-step instructions for using the Electronic Service
Request (ESR) tool for submitting problems electronically: http://www.ibm.com/software/ websphere/support/d2w.html
Sign up to receive weekly technical My Notifications emails: http://www.ibm.com/software/ support/einfo.html
IBM Support Wants to Hear From You!
1. Visit any product support pages on IBM.com.
2. Click on “Participate in Questionnaire” on top right of page.
3. Takes 5-10 minutes to complete.