Tag Archive | mq

Multi-hopping with 4 Qmgrs

Just an Extension for Multi-hopping messages between 4  Queue Managers

Reference Links :
1) Distributed MQ communication Part 1
2) Distributed Two Way MQ Communication — Part2
3) MultiHopping with 3 Qmgrs

MultiHopping With 4 Qmgrs

Quick Reference Guide
Multi-hopping with 4 QMGRS , QMA–> QMB–> QMC–> QMD

On Queue Manager QMA
bash-3.2$ crtmqm QMA
bash-3.2$ strmqm QMA
bash-3.2$ runmqsc QMA
DEFINE QLOCAL(QMA.XMITQ) USAGE(XMITQ)
DEFINE CHANNEL(QMA.TO.QMB) CHLTYPE(SDR) CONNAME(‘192.168.111.128(1420)’) XMITQ(QMA.XMITQ)
DEFINE QREMOTE(QMC.RQ) RNAME(QMC.LCQ) RQMNAME(QMC) XMITQ(QMA.XMITQ)
DEFINE QREMOTE(QMD.RQ) RNAME(QMD.LCQ) RQMNAME(QMD) XMITQ(QMA.XMITQ)
START CHANNEL(QMA.TO.QMB)
DISPLAY CHSTATUS(*)On Queue Manager QMBbash-3.2$ crtmqm QMB
bash-3.2$ strmqm QMB
bash-3.2$ runmqsc QMB
DEFINE LISTENER(QMB.LISTENER) TRPTYPE(TCP) PORT(1420) IPADDR(192.168.111.128)
START LISTENER(QMB.LISTENER)
DEFINE CHANNEL(QMA.TO.QMB) CHLTYPE(RCVR)
DEFINE CHANNEL(QMB.TO.QMC) CHLTYPE (SDR) TRPTYPE(TCP) CONNAME(‘192.168.111.128(1421)’) XMITQ(QMB.XMITQ)
DEFINE QLOCAL(QMB.XMITQ) USAGE(XMITQ)– Qmgr Alias for QMC and QMD
DEFINE QREMOTE(QMC) RQMNAME(QMC) RNAME(”) XMITQ(QMB.XMITQ)
DEFINE QREMOTE(QMD) RQMNAME(QMD) RNAME(”) XMITQ(QMB.XMITQ)

START CHANNEL(QMA.TO.QMB)
START CHANNEL(QMB.TO.QMC)
DISPLAY CHSTATUS(*)
DISPLAY LSSTATUS(*)

On Queue Manager QMC

bash-3.2$ crtmqm QMC
bash-3.2$ strmqm QMC
bash-3.2$ runmqsc QMC
DEFINE LISTENER(QMC.LISTENER) TRPTYPE(TCP) PORT(1421) IPADDR(192.168.111.128)
START LISTENER(QMC.LISTENER)
DEFINE CHANNEL(QMB.TO.QMC) CHLTYPE(RCVR) TRPTYPE(TCP)
DEFINE CHANNEL(QMC.TO.QMD) CHLTYPE (SDR) TRPTYPE(TCP) CONNAME(‘192.168.111.128(1422)’) XMITQ(QMC.XMITQ)
DEFINE QLOCAL(QMC.XMITQ) USAGE(XMITQ)

— Qmgr Alias of QMD
DEFINE QREMOTE(QMD) RQMNAME(QMD) RNAME(”) XMITQ(QMC.XMITQ)
DEFINE QLOCAL(QMC.LCQ)
START CHANNEL(QMB.TO.QMC)
START CHANNEL(QMC.TO.QMD)
DISPLAY CHSTATUS(*)
DISPLAY LSSTATUS(*)

On Queue Manager QMD

bash-3.2$ crtmqm QMD
bash-3.2$ strmqm QMD
bash-3.2$ runmqsc QMD
DEFINE LISTENER(QMD.LISTENER) TRPTYPE(TCP) PORT(1422) IPADDR(192.168.111.128)
START LISTENER(QMD.LISTENER)
DEFINE CHANNEL(QMC.TO.QMD) CHLTYPE(RCVR) TRPTYPE(TCP)
DEFINE QLOCAL(QMD.LCQ)
START CHANNEL(QMC.TO.QMD)
DISPLAY CHSTATUS(*)
DISPLAY LSSTATUS(*)

Testing of MultiHopping on 4 Qmgrs

bash-3.2$ /opt/mqm/samp/bin/amqsput QMD.RQ QMA
Sample AMQSPUT0 start
target queue is QMD.RQ
This is 4 hopping qmgr

Sample AMQSPUT0 end

bash-3.2$ /opt/mqm/samp/bin/amqsget QMD.LCQ QMD
Sample AMQSGET0 start
message

 

Quick Reference For MQ Triggering

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
bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01

 

——- Run runmqtrm command on the Initiation Queue 
bash-3.2$ runmqtrm -m QMC01 -q TRIGGER.INITIATION.QUEUE

——- Put Messages using amqsput  
bash-3.2$/opt/mqm/sampl/bin/amqsput TRIGGER.Q QMC01

——- 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 
bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01

——- Check if the http Process is saterted by the just putting the Message in Queue
bash-3.2$ps –ef | grep http

 

 

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 
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 a Local Queue where Triggering is enabled with TRIGTYPE(FIRST)
DEFINE QLOCAL(TRIGGER.Q) TRIGGER TRIGDPTH(1) TRIGTYPE(FIRST)  INITQ(TRIGGER.INITIATION.QUEUE) PROCESS(TRIG.PROCESS)

——- Create Process with APPLICID /var/mqm/testscript.sh ie run testscript.sh on triggering
DEFINE PROCESS (‘TRIG.PROCESS’) APPLTYPE(UNIX) APPLICID(‘/var/mqm/testscript.sh‘)

——- Run runmqtrm command for the Initiation Queue 
bash-3.2$ runmqtrm -m QMC01 -q TRIGGER.INITIATION.QUEUE

——- Display QueueDepth before testing to ensure there are no messages in the QUEUE
bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01 | grep CURDEPTH

——- Put Messages using amqsput
bash-3.2$/opt/mqm/sampl/bin/amqsput TRIGGER.Q QMC01

——- 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
Also The script.log will let us know if it has run properly and triggering invoked.

——- Display QueueDepth 
bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01 | grep CURDEPTH

——- Check the script.log for ensuring the testscript.sh has run properly due to triggering
bash-3.2$tail -f /var/mqm/script.log

 

 


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
DEFINE PROCESS (‘TRIG.PROCESS’) APPLTYPE(UNIX) APPLICID(‘/var/mqm/testscript.sh‘)

——- Create a Local Queue where Triggering is enabled with TRIGTYPE(EVERY) 
ALTER QLOCAL(TRIGGER.Q) TRIGGER TRIGDPTH(1) TRIGTYPE(EVERY) INITQ(TRIGGER.INITIATION.QUEUE) PROCESS(TRIG.PROCESS)

——- Run runmqtrm command for the Initiation Queue
bash-3.2$ runmqtrm -m QMC01 -q TRIGGER.INITIATION.QUEUE

——- Display QueueDepth before testing to ensure there are no messages in the QUEUE
bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01 | grep CURDEPTH

——- Put Messages using amqsput , Put 3 messages to test
/opt/mqm/sampl/bin/amqsput TRIGGER.Q QMC01

——- 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
bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01 | grep CURDEPTH

——- Check the script.log for ensuring the testscript.sh has run properly due to triggering
bash-3.2$tail -f /var/mqm/script.log


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
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
DEFINE PROCESS (‘TRIG.PROCESS’) APPLTYPE(UNIX) APPLICID(‘/var/mqm/testscript.sh‘)

——- Create a Local Queue where  Triggering is enabled
ALTER QLOCAL(TRIGGER.Q) TRIGGER TRIGDPTH(3) TRIGTYPE(DEPTH) INITQ(TRIGGER.INITIATION.QUEUE) PROCESS(TRIG.PROCESS)

——- Run runmqtrm command for the Initiation Queue
bash-3.2$ runmqtrm -m QMC01 -q TRIGGER.INITIATION.QUEUE

——- Display QueueDepth before testing to ensure there are no messages in the QUEUE
bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01 | grep CURDEPTH

——- Put 3 Messages in the TRIGGER.Q  using amqsput
/opt/mqm/sampl/bin/amqsput TRIGGER.Q QMC01

——- Display QueueDepth before testing to ensure there are no messages in the QUEUE
bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01 | grep CURDEPTH

——- 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
bash-3.2$tail -f /var/mqm/script.log

——- 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.

——- So for every time trigger is invoked due to QUEUE DEPTH ( TRIGDPTH ) the Triggering needs to be enabled again 

——- Reenable the Triggering for the TRIGGER.Q
bash-3.2$ echo “ALTER QLOCAL(TRIGGER.Q) TRIGGER ” | runmqsc QMC01

 

Example4 :Runmqtrm as a SERVICE

 

——- Start Queue Manager
bash-3.2$ strmqm QMC01
bash-3.2$ runmqsc QMC01
 

——- Define Service for TRIGGER Monitor
DEFINE SERVICE(TRIGMON) CONTROL(QMGR) SERVTYPE(SERVER) +
STARTCMD(‘+MQ_INSTALL_PATH+bin/runmqtrm’) +
STARTARG(‘-m +QMNAME+ -q SYSTEM.DEFAULT.INITIATION.QUEUE’) +
STOPCMD(‘+MQ_INSTALL_PATH+bin/amqsstop’) +
STOPARG(‘-m +QMNAME+ -p +MQ_SERVER_PID+’) STDOUT(‘/tmp/TrigMon.stdout’) +
STDERR(‘/tmp/TrigMon.stderr’)

 

——- Start the Service
START SERVICE(TRIGMON)

 

——- View the Services attributes
DISPLAY SVSTATUS(TRIGMON)

 

——- Triggering Std Out and Error
bash-3.2$ ls -lt /tmp/Trig*
-rw-r–r– 1 mqm mqm 239 2014-03-20 13:18 /tmp/TrigMon.stdout
-rw-r–r– 1 mqm mqm 0 2014-03-20 13:18 /tmp/TrigMon.stderr

 

 

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

 

Setting up MQ Triggerring

MQ Triggering
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

mqtriggering

1) A message is put to a queue defined as triggered.
2) If a series of conditions are met, the queue manager sends a trigger message to an initiation queue.
3) This is called a trigger event.
4) 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.
5) Trigger monitors may be built-in or user defined

Some links for more elaborate details on triggering
https://hursleyonwmq.wordpress.com/2007/02/09/triggering-checklist/
http://blog.niklasottosson.com/?p=598
http://www-01.ibm.com/support/docview.wss?uid=swg27039569
http://www-01.ibm.com/support/docview.wss?rs=171&uid=swg27008375
http://www-01.ibm.com/support/docview.wss?uid=swg27041673&aid=1

Types of triggering:
1. Channel Triggering
2. Application Triggering
3. Client Triggering

Modes of Triggering
Trigger on first message- Call a program when depth of queue goes from 0 to 1
Trigger on every message- Call a program for every message entering the queue
Trigger on depth- Call a program when depth of queue gets to a certain number like on 10 messages

In this tutorial I will display the minimal steps to start the application triggering

High level steps for Application triggering
a) Create an initiation queue or use the default SYSTEM.DEFAULT.INITIATION.QUEUE.
b) Create a process definition.
c) Create or alter a local or model queue.
d) Associate the initiation queue and process definition with the local queue, and specify the trigger attributes .

Environment Details :
MQ Version : 7.0
OS : Redhat Linux
TYPE : Application Triggering
MODE : FIRST,EVERY,DEPTH

For a QUICK REFERENCE on TRIGGERING refer to  http://webspherepundit.com/?p=1699

######################################################################################
######################################################################################

Example 1
Trigerring Scenario : To start the http process on a First message put in the Queue

Assumption
a) The http process can be started an stopped using mqm user ( the method to stop/start http as mqm is not covered in this tutorial .. may be for some other day
NOTE : It can be any process/script which you want to start , I used it to get the proper understanding of starting a process using trigerring
b) Your queue manager is created and started
NOTE : create a queue manager : crtmqm QMC01
Start the queue manager : strmqm QMC01

Step1 : Start the queue manager QMC01
As user mqm .. start the queue manager QMC01

bash-3.2$ strmqm QMC01

Step2 : Launch the MQSC prompt for the queue manager QMC01 using runmqsc

bash-3.2$ runmqsc QMC01

mqtriggering1

Step3 : Initiation Queue : Create an Initiation queue which the trigger monitor process will monitor

DEFINE QL(TRIGGER.INITIATION.QUEUE) like SYSTEM.DEFAULT.INITIATION.QUEUE

mqtriggering2

Step4 : Local Queue with Trigerring: Define a Local queue where you want the triggering to be set

NOTE : We will set the MODE as FIRST ie on the First message which the queue receives the trigger will be enabled and for the subsequent message the trigger will not be fired

DEFINE QLOCAL(TRIGGER.Q) TRIGGER TRIGDPTH(1) TRIGTYPE(FIRST) INITQ(TRIGGER.INITIATION.QUEUE) PROCESS(TRIG.PROCESS)

mqtriggering3

Step5 : Process Definition : Define the Process which needs to be started by the trigger
In this case its ‘/etc/init.d/httpd start’

DEFINE PROCESS (‘TRIG.PROCESS’) APPLTYPE(UNIX) APPLICID(‘/etc/init.d/httpd start’)

mqtriggering4

 

Complete Sample

mqtriggering5

Testing for Example 1
Step1 :  Stopping httpd as mqm to simulate the testing

mqtriggering6

Step2 : Check the Message depth of the Trigger Queue .. it will be zero now

bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01

mqtriggering7

Step3 :  Start the MQ triggering Process which will monitor the initiation queue

bash-3.2$ runmqtrm -m [QMGR Name] -q [INITIATION QUEUE] 

It can be run in the background using

bash-3.2$ runmqtrm -m [QMGR Name] -q [INITIATION QUEUE]  &

mqtriggering43

runmqtrm can be run as a service too in MQ & It will be covered later in this blog

bash-3.2$ runmqtrm -m QMC01 -q TRIGGER.INITIATION.QUEUE

mqtriggering8

Step4 :
Open another Putty session and Put the Message to the TRIGGER.Q and see the response of the runmqtrm on the other session
Put a message in TRIGGER.Q using ./amqsput TRIGGER.Q 

mqtriggering9

Step5 :  Check the TRIGGER.Q depth count it will be 1

bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01

mqtriggering10

Step6 : Check the http process .. it should be started now using ps –ef | grep http

mqtriggering11
######################################################################################
######################################################################################

Example 2
Trigerring Scenario : 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 )

Step1 :  Create a test script as per the sample below  (It can be any script of your choice)
This script will use amqsgbr output and send it to a  file /var/mqm/script.log

Create a script file testscript.sh

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
############################

mqtriggering12

Step2 :  Change the permission to make it executable

bash-3.2$ chmod 755 /var/mqm/testscript.sh

Step3 :  Testing the script : Test this script works

bash-3.2$ cd /opt/mqm/samp/bin
bash-3.2$ ./amqsput TRIGGER.Q QMC01
Sample AMQSPUT0 start
target queue is TRIGGER.Q
This is Script TestSample AMQSPUT0 end
bash-3.2$bash-3.2$ /var/mqm/testscript.sh
bash-3.2$
bash-3.2$ tail -f /var/mqm/script.log
Thu Jun 11 12:47:23 IST 2015

mqtriggering13

Enabling Triggering to run this script

Now that we know the script works , Put it for triggering

Step1 : We will use the same example1 only we will alter the process definition with APPLICID(‘ /var/mqm/testscript.sh’)
we will alter APPLICID(‘/etc/init.d/httpd start’)”  with  APPLICID(‘ /var/mqm/testscript.sh’)  

ALTER PROCESS (‘TRIG.PROCESS’) APPLTYPE(UNIX) APPLICID(‘/var/mqm/testscript.sh’)


mqtriggering14

Step2 : Check the Queue Depth of Trigger Queue .. IT should be “Zero”

bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01 | grep CURDEPTH


mqtriggering15

Step3 : Run the “runmqtrm” command

bash-3.2$ runmqtrm -m QMC01 -q TRIGGER.INITIATION.QUEUE

Testing for Example 2

NOTE: use ./amqsget TRIGGER.Q or CLEAR TRIGGER.Q to clear the messages in  TRIGGER.Q before starting the test 

Step1: Put a message in the TRIGGER.Q

mqtriggering16

Step2 : View the runmqtrm console

mqtriggering17

Step3 : Tail the script has run by seeing the logs

mqtriggering18

 

Now even if we put more messages in the Queue TRIGGER.Q the trigger will only happen once ( ie the First message ie when the Queue Depth goes from Zero to One .

For eg : The initial queue depth of “TRIGGER.Q” is zero .. Then I put 3 messages in it

mqtriggering20

mqtriggering22

But with the runmqtrm  we see that the script only ran only ONCE.

mqtriggering21

mqtriggering23

With this we have simulated a situation wherein the only the first message to a queue ( Queue depth Zero to One)  will trigger the  script to run 

######################################################################################

######################################################################################

Example 3

Trigerring Scenario : We will Test the Trigerring method for EVERY Message instead of the FIRST message entering the Trigger queue.
I will use the same object created in the previous Example 2 

bash-3.2$  runmqsc QMC01

Step1 : Alter the Definitions of the TRIGGER.Q with  TRIGTYPE(EVERY)

ALTER QLOCAL(TRIGGER.Q) TRIGGER TRIGDPTH(1)  TRIGTYPE(EVERY) INITQ(TRIGGER.INITIATION.QUEUE) PROCESS(TRIG.PROCESS)

mqtriggering24

Step2 : Run the runmqtrm for the Initiation Queue

bash-3.2$ runmqtrm -m QMC01 -q TRIGGER.INITIATION.QUEUE

 Testing for Example 3

Step1 : Check the Current Depth of the TRIGGER.Q its “Zero”
NOTE: use ./amqsget TRIGGER.Q or CLEAR TRIGGER.Q to clear the messages in  TRIGGER.Q

mqtriggering26

Step2 :Clear the script logs

mqtriggering27

Step3 :Put 4 messages using amqsput TRIGGER.Q . So if our configurations are corrent for each message the trigger monitor will execute the testsctipt.sh

mqtriggering28

Step4 :Check the output of the trigger ie runmqtrm. You will see for each message the testscript.sh is run

mqtriggering29

Step5 : Check the Logs to ensure the script has run for each trigger

bash-3.2$ tail -f /var/mqm/script.log


mqtriggering30

bash-3.2$ echo “DISPLAY QL(TRIGGER.Q) CURDEPTH TRIGGER ” | runmqsc QMC01 | grep CURDEPTH

######################################################################################

######################################################################################

Example 4
Trigerring Scenario : 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

We will use the same Example 2 for this test 

Step1 : Clear the queue TRIGGER.Q of the messages

bash-3.2$ ./amqsget TRIGGER.Q QMC01
bash-3.2$ >/var/mqm/script.log

mqtriggering32

 

Step2 : Alter the Queue definitions for TRIGDPTH(3) TRIGTYPE(DEPTH)

ALTER QLOCAL(TRIGGER.Q) TRIGGER TRIGDPTH(3) TRIGTYPE(DEPTH) INITQ(TRIGGER.INITIATION.QUEUE) PROCESS(TRIG.PROCESS)

mqtriggering33

Step3 : Run the runmqtrm for the Initiation Queue

bash-3.2$ runmqtrm -m QMC01 -q TRIGGER.INITIATION.QUEUE

Testing for Example 4

Step1 : Put 3 messages in the Queue TRIGGER.Q .. Observe that until we put 3 messages in the TRIGGER.Q the triggering is not fired

 

mqtriggering35

 

Step2 :The trigger is run only one when the Queue Depth reaches 3 messages
Check the output of the script which writes to the logs script.log to ensure that the script has run only once when the Depth is 3 

mqtriggering38

 

One thing to observe is that once the triggering is fired for TRIGTYPE( DEPTH) the triggering is disabled for the Queue

Here we can see that the Triggering is disabled “NOTRIGGER”  onces the triggering is fired

mqtriggering39

We need to enable TRIGGERING Again for the TRIGGER.Q as below

bash-3.2$ echo “ALTER QLOCAL(TRIGGER.Q) TRIGGER ” | runmqsc QMC01


mqtriggering40

 

NOTE : An Application can use MQSET within it to re-enable the Triggering the QUEUE

######################################################################################

######################################################################################

Runmqtrm as a SERVICE

Instead of running runmqtrm from the putty prompt , A better way to runmqtrm is as a service
Step1 : Define Service

DEFINE SERVICE(TRIGMON) CONTROL(QMGR) SERVTYPE(SERVER) +
STARTCMD(‘+MQ_INSTALL_PATH+bin/runmqtrm’) +
STARTARG(‘-m +QMNAME+ -q SYSTEM.DEFAULT.INITIATION.QUEUE’) +
STOPCMD(‘+MQ_INSTALL_PATH+bin/amqsstop’) +
STOPARG(‘-m +QMNAME+ -p +MQ_SERVER_PID+’) STDOUT(‘/tmp/TrigMon.stdout’) +
STDERR(‘/tmp/TrigMon.stderr’)


mqtriggering44

Step2 :Start the Service

START SERVICE(TRIGMON)

mqtriggering45

Step3 :View the Services attributes

DISPLAY SVSTATUS(TRIGMON)


mqtriggering46

mqtriggering48
Step4 : Notice that the output files defined for the trigger monitor are created:

STDOUT(‘/tmp/TrigMon.stdout’)
STDERR(‘/tmp/TrigMon.stderr’)

Step5 : List the OutPut files

bash-3.2$ ls -lt /tmp/Trig*
-rw-r–r– 1 mqm mqm 239 2014-03-20 13:18 /tmp/TrigMon.stdout
-rw-r–r– 1 mqm mqm 0 2014-03-20 13:18 /tmp/TrigMon.stderr

 

bash-3.2$ cat /tmp/TrigMon.stdout
5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED.
03/20/2014 01:18:24 PM : WebSphere MQ trigger monitor started.
__________________________________________________
03/20/2014 01:18:25 PM : Waiting for a trigger message

At this point, notice that the trigger monitor has not handled any messages yet:

 

 

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