WebSphere MQ triggering techniques

 
PHP Freelancer

Overview

How to make a program to run whenever a new message is received on a specific queue? There are two ways to implement this "MQ trigger" features:

  1. Use triggers function of WebSphere MQ

    WebSphere MQ have a function called "Trigger Monitor". It can listen to queue continuously and trigger a program(written by you) to run when messages are received.

    To use this function you (at least) have to:
    - Configure the MQ Server for trigger (e.g. create / associate initiation queue)
    - Write the program to handle the trigger event, usually this is a standalone program
    - Configure and start Trigger Monitor to monitor the target initiaition queue

    I did not use this method for MQ triggering, as this method seems quite troublesome and require lots of configuration. Instead I use the next method to achieve MQ trigger. You may refer to this WebSphere MQ help page for more info on this method.

  2. Deploy a Message-Driven Bean to WebSphere App Server connected to the MQ

    A "Message-Driven Bean" (MDB) is an "Enterprise Java Bean" (EJB) which acts as a JMS message listener. It can listen to a port and be started when a JMS message arrive. For more info, please refer to this J2EE Tutorial.

    To use JMS technology to achieve MQ triggering function, we first need a WebSphere Application Server (I used WebSphere v6.0). Other J2EE App Server would need WebSphere MQ integration to work. Then we need to configure WebSphere MQ as JMS provider in the App Server. After that, we have to configure some JMS stuff on the App Server, write the MDB and deploy it.

    This great tutorial at IBM have everything you need to know to do MQ trigger thru JMS. It even come with sample code! Please refer to this page for importing the sample code.

    I would try to outline the steps here:

    1. Create the queue (As I already have a queue I skipped this step)
    2. Define the JMS connection factory for WebSphere MQ
    3. Define the JMS queue
    4. Define the listener ports
    5. Write the MDB, deploy it to App Server
    6. Restart App Server, done!

Reference

  1. Starting WebSphere MQ applications using triggers
  2. Make WebSphere MQ the JMS provider for Apps deployed in WebSphere
  3. How WebSphere Application Server V6 handles poison messages
  4. What Is a Message-Driven Bean? – The J2EE Tutorial
 

Discussion

What do you think? Leave a comment. Alternatively, write a post on your own weblog; this blog accepts trackbacks [trackback url].

Leave a Reply