Fresher
Fresher

Reputation: 73

How can we use a trigger in IBM MQ?

I have reached the ibm site but I cant find the actual logic to make use of the trigger.

I have done the below code but how can i receive an intimation from the trigger?

public void setTrigger()
        {
        try{
            Queue = QMGR.accessQueue(queueName, (MQC.MQOO_INQUIRE+MQC.MQOO_SET));
            Queue.setTriggerControl(1);
            Queue.setTriggerType(2);
            }
        catch(Exception e){
            System.out.println("------------------------");
            System.out.println("trigger method");
            System.out.println("------------------------");
            System.out.println(e);
            System.out.println("************************");
            }
        }

How can I get the intimation whenever message came.

Upvotes: 3

Views: 2440

Answers (1)

Roger
Roger

Reputation: 7476

First off, don't do the triggering setup via an application. It is a waste of time.

Secondly, read & understand these MQ web pages:

Third, for Java applications, create a batch file or Unix script to set up any environment variables i.e. CLASSPATH and set batch file or Unix script in the PROCESS's APPLICID field.

Fourth, after you do the MQSC definition for the queue and process, don't forgot to start the trigger monitor (otherwise nothing will be triggered).

Fifth, if you set Trigger Type of First then make absolutely sure that the triggered application reads every message from the queue before exiting.

Sixth, triggering (Trigger First) is only good for scenarios when there are large gaps between messages or large gaps between burst of messages. If you are receiving messages every second or 2 then triggering is not good because the application start, process & exit every second or 2. And if it is a Java application, you will always have the JVM load time.

Seventh, if what you really wanted was Message CallBack (Asynchronous) rather than MQ Triggering then go read: Asynchronous consumption of IBM MQ messages

Upvotes: 6

Related Questions