2007年12月9日 星期日

[MQueue] IBM WMQ Trigger

.
. IBM WebSphere MQ v6.0
. Chapter 3.2 - IBM WebSphere MQ Trigger
.

=== Components of Triggering ===
Program A MQPUT A-Q (put a message on an application Queue)--->
 [QM]
  (1)→ Application Queue (which is enabled for triggering)

(If the conditions for triggering are met, a trigger event occurs, and the QM examines the Process Object referenced by the Application Queue)
  (2)→ Process Object

(The QM creates a trigger message whose fields contain information copied from certain attributes of the Process Object and the Application Queue. The QM puts the trigger message on an Initiation Queue.)
  (3)→ Initiation Queue
 [/QM]

(A long running program called a trigger monitor gets the trigger message, examines otscontents, and ...)
  (4)—→ MQGET I-Q (Trigger Monitor)

(... and starts Program B, passing the entire trigger message as a parameter.)
  (5)—→ MQGET A-Q Program B

(Program B opens the Application Queue and gets messages from it.)
  (6)—→ MQGET A-Q Program B


=== Queue Attributes Controlling Triggering ===
※ TRIGGER/NOTRIGGER 是 Queue 的一個參數 :

DEFINE QLOCAL(QL.QT1) TRIGGER +
 PROCESS(ECHO) +
 INITQ(SYSTEM.DEFAULT.INITIATION.QUEUE)


 - TRIGGER or NOTRIGGER : Triggering is active or not active respectively.
 - TRIGMPRI(integer) : 可設定Priority多少以上才Triggering.
 - TRIGTYPE(FIRST or DEPTH or EVERY or NONE) : Triggering四種Type.
 - TRIGDPTH(integer) : 對應 TRIGTYPE(DEPTH)
 - TRIGDATA(string) : Data that is copied into the Trigger Message.


=== PROCESS Attributes (定義PROCESS) ===
DEFINE PROCESS(ECHO) +
 APPLICID('/opt/mqm/samp/bin/amqsech')

DEFINE PROCESS(ECHO) REPLACE +
 APPLICID('C:\Program Files\IBM\WebSphere MQ\Tools\c\Samples\Bin\amqsech.exe')

 - APPLICID(string) : Name of the application to be started.
 - APPLTYPE(UNIX or WINDOWS)
 - ENVRDATA(string) : For use by the trigger monitor.
 - USERDATA(string) : For use by the trigger monitor or the started application.

※ MQ commands for PROCESSes :
 DEFINE PROCESS
 ALTER PROCESS
 DELETE PROCESS
 DISDPLAY PROCESS


=== Fields in the Trigger Message (structure MQTMC2) ===
1. Copied from the corresponding attributes of the application Queue :
 - QName
 - TriggerData
 - ProcessName

2. Copied from the corresponding attributes of the process object :
 - ApplType (MQAT_CSIC, MQAT_UNIX, MQAT_WINDOWS)
 - ApplId
 - EnvData
 - UserData

3. QMgrName :


====== 啟動 Trigger Monitor ======
1. To start a trigger monitor :
 # runmqtrm -m QMgrName -q InitiationQName
 (I-Q 預設會用 SYSTEM.DEFAULT.INITIATION.QUEUE )
 例如 : # runmqtrm -m QMC00A -q SYSTEM.DEFAULT.INITIATION.QUEUE

2. Command issued by trigger monitor to start the application :
# (ApplId) "(MQTMC2)" (EnvData)

3. Other trigger monitors :
 - Client trigger monitor
 - CICS


=== Trigger Monitor Errors (狀況處理) ===
1. Messages are produced by Normal activities (正常), for example :
 - Trigger monitor started.
 - Waiting for a trigger message.
 - Trigger monitor ended.

2. Messages are produced by Abnormal conditions (異常) , for example :
 - Initiation Queue could not be opened.
 - Use of trigger monitor not authorized.
 - Error starting triggered application.

3. A message may be written to :
 - The standard output device.
 - An error log.

4. A Trigger Message is written to the Dead Letter Queue if :
 - The Trigger Message structure is not valid.
 - The Trigger Message specifies an unsupported application type.
 - The Trigger monitor is enable to start the specified application.


======Sample Programs======
# amqsreq QName [QMgrName]
1. This program is invoked from a Command Prompt in exactly the same way as amqsput, but accepts three input parameters.
2. The program reads lines of text from the standard input device, converts them to request messages, and puts the messages on the named Queue.
3. Each request message requires a Reply-to-Queue name specified as the third input parm. If it is ommitted, the name defaults to SYSTEM.SAMPLE.RELAY .
(C:\Program Files\IBM\WebSphere MQ\Tools\mqsc\Samples\amqscos0.tst)
4. If the name resolves to Model Queue, a Dynamic Queue will be created.
5. When the input of text is terminated (null line or EOF), the program waits for the reply messages and writes the text whin each reply message to standard output device.

 例如:# amqsreq QL.TQ1 QMC00A

# amqsech
1. This program is designed to be started by a Trigger Monitor and not from a Command Prompt.
2. The program connects to the Queue Manager named in the structure passed to it by the Trigger Monitor and opens the Queue also named in the structure. This is called the Request Queue in the description that follows.
3. The program gets a message from the Request Queue, create a new message containing the same application data as the original message, and puts the new message on the Reply-to-Queue named in the message descriptor of the original message.
4. The program then gets each of the remaining messages on the Request Queue in turn and generates a reply in the same way.
5. When the Request Queue is empty, the program closes the Queue and disconnects from the Queue Manager.

# amqsinq
1. This program is designed to be started by a Trigger Monitor in the same way as amqsech.
2. The program connects to the Queue Manager, opens the Request Queue, gets a message from the Queue, an interprets the application data as the name of a Queue.
3. The program opens this Queue, calls MQINQ to inquire on the values of three of its attributes, constructs a reply message contain these values, and puts the message on the Reply-to-Queue.
4. The program then gets each of the remaining messages on the Request Queue in turn and generates a reply in the same way.
5. When the Request Queue is Empty, the program closes the Queue and disconnects from the Queue Manager.

沒有留言:

張貼留言