For More detailed information MQ TRIGGERING click below
http://webspherepundit.com/?p=1605
These are the quick references for setting up simple TRIGGERING with few different examples for FIRST , EVERY and DEPTH Modes
Example1 :To start the http process on a First message put in the Queue
NOTE : The method to stop/start http as mqm is not covered in this tutorial .
Http Process is just used for example .. you can use any process as per your requirement ( Ensure that mqm user should be able to stop/start those processes)
——- Start QMgr bash-3.2$ strmqm QMC01 bash-3.2$ runmqsc QMC01 ——- Create Initiation Queue DEFINE QL(TRIGGER.INITIATION.QUEUE) like SYSTEM.DEFAULT.INITIATION.QUEUE ——- Create Local Queue with Triggering Options with TRIGTYPE(FIRST) DEFINE QLOCAL(TRIGGER.Q) TRIGGER TRIGDPTH(1) TRIGTYPE(FIRST) INITQ(TRIGGER.INITIATION.QUEUE) PROCESS(TRIG.PROCESS) ——- Create Process with APPLICID ( /etc/init.d/httpd start ) It can be any process as per env DEFINE PROCESS (‘TRIG.PROCESS’) APPLTYPE(UNIX) APPLICID(‘/etc/init.d/httpd start’) ——- Display QueueDepth before testing to ensure there are no messages in the QUEUE
——- Run runmqtrm command on the Initiation Queue ——- Put Messages using amqsput ——- On the first message put to the QUEUE the triggering would be fired , view the putty console where runmqtrm is running .. here we will see if the trigger event is run and triggering invoked and http process started ——- Display QueueDepth ——- Check if the http Process is saterted by the just putting the Message in Queue |
Example2: Enable triggering to start a unix script with a receipt of a message .
In this example we will be running a script instead of starting a process with trigerring set for FIRST( ie On the arrival of the first message )
——- Create a script when run will browse the message using amqsgbr and redirect to a script.log bash-3.2$ vi /var/mqm/testscript.sh ############################ echo `date` >> /var/mqm/script.log /opt/mqm/samp/bin/amqsgbr TRIGGER.Q QMC01 | grep “[1-9] <” >> /var/mqm/script.log echo “==========================” >> /var/mqm/script.log ############################ ——- Make the script executable ——- Start Queue Manager ——- Create an Initiation Queue ——- Create a Local Queue where Triggering is enabled with TRIGTYPE(FIRST) ——- Create Process with APPLICID /var/mqm/testscript.sh ie run testscript.sh on triggering ——- Run runmqtrm command for the Initiation Queue ——- Display QueueDepth before testing to ensure there are no messages in the QUEUE ——- Put Messages using amqsput ——- On the first message put to the QUEUE the triggering would be fired and and the script testscript.sh is run . view the putty console where runmqtrm is running .. here we will see if the trigger event is run and triggering invoked ——- Display QueueDepth ——- Check the script.log for ensuring the testscript.sh has run properly due to triggering |
Example3 :We will Test the Triggering method for EVERY Message instead of the FIRST message entering the Trigger queue
——- Create a script when run will browse the message using amqsgbr and redirect to a script.log bash-3.2$ vi /var/mqm/testscript.sh ############################ echo `date` >> /var/mqm/script.log /opt/mqm/samp/bin/amqsgbr TRIGGER.Q QMC01 | grep “[1-9] <” >> /var/mqm/script.log echo “==========================” >> /var/mqm/script.log ############################——- Make the script executable bash-3.2$ chmod 755 /var/mqm/testscript.sh——- Start Queue Manager bash-3.2$ strmqm QMC01 bash-3.2$ runmqsc QMC01——- Create an Initiation Queue DEFINE QL(TRIGGER.INITIATION.QUEUE) like SYSTEM.DEFAULT.INITIATION.QUEUE ——- Create Process with APPLICID /var/mqm/testscript.sh ie run testscript.sh on triggering ——- Create a Local Queue where Triggering is enabled with TRIGTYPE(EVERY) ——- Run runmqtrm command for the Initiation Queue ——- Display QueueDepth before testing to ensure there are no messages in the QUEUE ——- Put Messages using amqsput , Put 3 messages to test ——- For every Message put in the Queue TRIGGER.Q , a trigger event would start and the script would run 3 times and the output captured in script.log . View the putty console where runmqtrm is running .. here we will see if the trigger event is run and triggering invoked ——- Display QueueDepth before testing to ensure there are no messages in the QUEUE ——- Check the script.log for ensuring the testscript.sh has run properly due to triggering |
Example4 :We will test the triggering for the Depth of the Queue ie when the QUEUE Depth reaches the defined setting a triggering should be fired
——- Create a script when run will browse the message using amqsgbr and redirect to a script.log bash-3.2$ vi /var/mqm/testscript.sh ############################ echo `date` >> /var/mqm/script.log /opt/mqm/samp/bin/amqsgbr TRIGGER.Q QMC01 | grep “[1-9] <” >> /var/mqm/script.log echo “==========================” >> /var/mqm/script.log ############################ ——- Make the script executable
——- Start Queue Manager ——- Create Process with APPLICID /var/mqm/testscript.sh ie run testscript.sh on triggering ——- Create a Local Queue where Triggering is enabled ——- Run runmqtrm command for the Initiation Queue ——- Display QueueDepth before testing to ensure there are no messages in the QUEUE ——- Put 3 Messages in the TRIGGER.Q using amqsput ——- Display QueueDepth before testing to ensure there are no messages in the QUEUE ——- Only onces the Depth of the QUEUE has reached to the TRIGDPTH ie “3” messages the triggering will be invoked. It can be seen from the putty console of “runmqtrm” and also visible from the /var/mqm/script.log the triggering result ——- Check the script.log for ensuring the testscript.sh has run properly due to queue depth triggering ——- After the triggering is fired the Triggering for the QUEUE “TRIGGER.Q” in the Example , It gets disabled .. ——- It needs to be Re-Enabled using below command or use MQSET to renable the TRIGERR from the Application. ——- Reenable the Triggering for the TRIGGER.Q |
Example4 :Runmqtrm as a SERVICE
——- Start Queue Manager bash-3.2$ strmqm QMC01 bash-3.2$ runmqsc QMC01 ——- Define Service for TRIGGER Monitor
——- Start the Service
——- View the Services attributes
——- Triggering Std Out and Error |
To get automated mail updates of my Posts..
Please subscribe to the site http://webspherepundit.com
And also like the Facebook Page
https://www.facebook.com/webspherepundit