CKTI - A walkthrough
Anubhuti Kaushik 060000XD9S Visits (1302)
TXSeries 8.1 beta has introduced a new feature for better & seamless integration of TXSeries CICS applications with WebSphere MQ Series(WMQ). This feature provides a new transaction called CKTI, which is the TXSeries trigger monitor. CKTI can help you monitor trigger events generated for MQ application queues by WebSphere MQ and then take appropriate action like trigger a CICS transaction.
But before dwelling into the details of CKTI, first, let us revise the basics!
What are Triggers
Certain conditions, which when are met, an event should happen are called triggers.
Let’s start with a easy sample. You have a small sales app of a departmental store which tracks the amount of sales every employee is making. To keep the employees motivated and enthused, the app is designed such that after every ten sales an employee makes, it sends him summary of those 1ast ten sales as well as the overall summary of his total sales, and a congratulatory note. Looks simple, right!
To do this we will need an application which tracks the individual sales made by each employee. This could be TXSeries CICS application or a WMQ application. Call this transaction as SALE. Another transaction called SUMR, will do a summary of last ten sales made and send a note. Once a sale is done, SALE will update a central database and put a message in a WebSphere MQ application queue. Let’s call it CICS.LOCAL.QUEUE.
A trigger can be defined which will be generated when there are 10 messages in the CICS.LOCAL.QUEUE.
Here is the WMQ command to create an application queue and associate it with a trigger and Initiation Queue
DEFINE QLOCAL (CICS.LOCAL.QUEUE) +
DESCR('Local Queue') +
TRIGGER TRIGTYPE(DEPTH) +
DESCR('Local Queue use as init queue for triggering') +
Behind the scenes
Once, a trigger condition is met, WebSphere MQ puts a trigger message in a special queue called Initiation Queue, which is associated with that application queue.
This trigger message usually contains the name of the transaction and the associated data which should be invoked when this trigger message is consumed. Now someone needs to process this trigger message. The application which processes the trigger message is called Trigger Monitor.
What is Trigger Monitor
A trigger monitor is an application that processes the trigger messages that are put on initiation queues when a trigger event occurs. The trigger monitor reads the trigger message and takes appropriate action, based on the data in the trigger message. Normally, this action would be to start some other application to process the queue that caused the trigger message to be generated. The trigger monitor must pass sufficient information to the program that it is starting so that the program can perform the right actions on the right application queue. CKTI is TXSeries supplied Trigger Monitor and Task Initiator.
How to associate a Trigger Monitor with an INIT Queue
Define Process command in MQ can be used to associate trigger monitor with a particular INIT Queue. To define CKTI as the trigger monitor, PROCESS attribute was used in Listing 1.
DESCR('Process def for cics application') +
This command tells WebSphere MQ that TXSeries supplied CKTI transaction will be used as Trigger Monitor, and the Trigger Monitor should start the transaction SUMR once it consumes the trigger message.
How to enable CKTI in TXSeries
To enable CKTI in TXSeries you need to create a new MQD stanza entry. This can be done either through WebConsole or through command line. Following is the command.
cicsadd -c mqd –r <cics_region> QM MQMg
This command lets you define an MQD stanza entry for one INITQ. If you have multiple INIT queues in your solution, you should define separate MQD entry for each of them. At region startup, TXSeries starts one CKTI trigger monitor for each MQD entry. Each CKTI transaction occupies one TXSeries application server process. So make sure you define your MAXServers in RD stanza appropriately. TXSeries provides an environment variable CICS
Behind the scenes
When a message arrives on Initiation Queue, CKTI trigger monitor which is listening on that initiation queue, starts the transaction through EXEC CICS START TRANSID, specified using the DEFINE PROCESS command of MQ. In our sample it was SUMR.
A program can use the EXEC CICS RETRIEVE command with the RTRANSID option to determine how the program was started; if the value returned is CKTI, the program was started by the CICS-WebSphere MQ trigger monitor.
The figure below describes the flow of events.
TXSeries supplies another administration transaction called CKQC, which can be used to start, stop or administer Initiation Queues.
Advantages of using CKTI over traditional approach
CKTI occupies one application server to monitor multiple InitQueues.
Any changes need to be made only in the definition of triggers or the transaction being invoked by CKTI.