Author |
Message
|
mca |
Posted: Tue Apr 19, 2005 8:34 am Post subject: [SOLVED] code change/triggertype from "every" - &q |
|
|
Disciple
Joined: 09 Mar 2005 Posts: 196
|
MQGet Program(java):
String QM = "QM";
String QUEUE = "Q";
//code for connecting to the specified Queue and Queue Manager.
//call the message parser program and come back with the parsed values
//send the parsed values and Invoke application program and do the work
// ---->code to check if any more messages in Q.
YES --> Invoke MQGet again
NO --> OutQueue.close(); qmgr.disconnect() ;
This is what my MQGet program is doing where it is getting triggered everytime. But i wanna change my code in such a way that it uses trigger type "first" and after doing the work and before disconnecting, it must check for any more messages messages in Q and if any it must execute MQGet again recursively until the Q is empty.
Can anyone tell what is the inbuilt function that checks for any more XML messages in Q? and how to call the same program in which its executing now ...
Last edited by mca on Wed May 11, 2005 7:23 am; edited 1 time in total |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Apr 19, 2005 8:40 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You write a loop around the mq get call.
When mqget returns a reason code of MQRC_NO_MORE_MESSAGES... you end your program.
Have you considered reading the Application Programming Guide? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
vennela |
Posted: Tue Apr 19, 2005 8:44 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Quote: |
Can anyone tell what is the inbuilt function that checks for any more XML messages in Q? |
The function is called for loop or while loop. |
|
Back to top |
|
 |
mca |
Posted: Tue Apr 19, 2005 8:52 am Post subject: |
|
|
Disciple
Joined: 09 Mar 2005 Posts: 196
|
Thanks jefflowrey and vennela for repling. What i mean by built-in function is some thing like:
if (built-in function to check for messges = TRUE) // if any message then return TRUE
CALL MQGet;
else
Disconnect Q;
and wait for trigger messge again. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Apr 19, 2005 8:57 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
jefflowrey wrote: |
Have you considered reading the Application Programming Guide? |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mca |
Posted: Tue Apr 19, 2005 8:59 am Post subject: |
|
|
Disciple
Joined: 09 Mar 2005 Posts: 196
|
I am going through that jefflowrey. Thanks for the suggestion. It is of sure use for my question |
|
Back to top |
|
 |
vennela |
Posted: Tue Apr 19, 2005 9:51 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
jefflowrey wrote: |
You write a loop around the mq get call.
When mqget returns a reason code of MQRC_NO_MORE_MESSAGES... you end your program.
|
MCA:
In the while loop, keep getting messages until you get an exception like 2033 or MQRC_NO_MORE_MESSAGES and end the program when you get that error. That means, you have no more messages. |
|
Back to top |
|
 |
EddieA |
Posted: Tue Apr 19, 2005 10:18 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
keep getting messages until you get an exception like 2033 or MQRC_NO_MORE_MESSAGES and end the program when you get that error |
I would suggest that you use a GET with WAIT for this. To avoid re-triggering the application if another message comes in seconds after you have processed the last one.
How long a wait will depend on the rate you expect messages to arrive. If they are very infrequent, then a short wait would be appropriate. However, if the messagers are more frequent, then a longer wait will avoid re-triggering the application too many times.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Apr 19, 2005 5:44 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
And anyways there should be no coding difference in the application for a trigger every or a trigger first. Read the books !! |
|
Back to top |
|
 |
mca |
Posted: Wed May 11, 2005 7:22 am Post subject: |
|
|
Disciple
Joined: 09 Mar 2005 Posts: 196
|
Thanks all for the replies.
What i meant by change code from "every" to "first" is keeping my MQGet program in loop until end of messages. If end of messages in Q, disconnect and wait for next "first" message. If i am using trigger type "first" i dont put my program in loop, but instead process the message and disconnect and wait for next "every" message. Now i am able to do this. by just adding one line before getting message:
Code: |
while(true)
MQGet
catch(error 2033-end of messages)
disconnect Q
|
Even though this is easy, initially i wasnot sure how to do this. So, need to post. Now got clear idea of how this works. thanks all for the replies. |
|
Back to top |
|
 |
|