IBM Websphere MQ 基礎6:進程定義process define

概念

      A process definition contains information about the application that starts in response to a trigger event on a queue manager. When you enable triggering on a queue, you can create a process definition and associate it with the queue. Each queue can specify a different process definition, or several queues can share the same process definition. If you create a process definition, the queue manager extracts the information from the process definition and places it in the trigger message for the trigger monitor to use.

      IBM MQ中process definition包含應用程序的必要信息用於響應QM上的觸發事件。當在queue上使能觸發後,可以創建一個 process definition用於關聯觸發事件。每個隊列可以指定不同的process definition,幾個不同的queue也可以共享相關的process。創建process definition後,QM從process definition中抽取信息並放置於觸發消息中以便觸發監控器使用。

If you want to trigger the start of a channel, instead of an application, you do not need to create a process definition because the transmission queue definition is used instead.

         若需求是觸發channel的啓動,則不需要創建process definition。

定義一個進程觸發

  • 創建啓動進入隊列管理器QmgrName
crtmqm QmgrName 
strmqm QmgrName 
runmqsc QmgrName 
  • 創建一個本地隊列並啓動觸發監控
DEFINE QLOCAL('TRIGGER.QUEUE') REPLACE DESCR('Application queue to test triggering') SHARE TRIGGER TRIGTYPE (EVERY) INITQ('TEST.INIT.QUEUE') PROCESS('IBMMQ.PROCESS') 

此觸發監控的initiation queue爲:TEST.INIT.QUEUE;

process define 爲:IBMMQ.PROCESS;

觸發類型爲:every,每次都觸發

  • 定義一個process
DEFINE PROCESS('IBMMQ.PROCESS') REPLACE DESCR('Process to test triggering') APPLICID('/var/mqm/test_process.sh')

應用程序爲一個腳本,腳本用於返回當前的腳本名$0

[mqm@t24app1sg ~]<20190602 11:14:20>$ cat test_process.sh

#!/bin/bash
echo "This is process:" $0
  • 定義initiation queue
DEFINE QLOCAL('TEST.INIT.QUEUE') REPLACE DESCR('Initiation queue to test triggering') 
  • 啓動觸發監控(linux視圖,而不是runmqsc視圖)
runmqtrm -m QmgrName -q TEST.INIT.QUEUE

       啓動後,觸發監控進程循環監控initiation queue。

  • 向TRIGGER.QUEUE中放置一條消息(另外開一個窗口,發送消息
amqsput TRIGGER.QUEUE QmgrName

測試效果:                     

如此,結果表明:測試正確。

    實際應用可根據應用場景對tigger type和process做很多文章。如基於深入depth的觸發,當queue的深度達到達到閾值時,啓動進程通知消息生產者暫緩消息發送。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章