|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Looping with get using wait interval? |
« View previous topic :: View next topic » |
Author |
Message
|
rtgordon |
Posted: Thu Nov 01, 2001 7:27 am Post subject: |
|
|
Apprentice
Joined: 27 Jun 2001 Posts: 34 Location: Lewisville, TX
|
Is it better to specify a wait interval and a simple get (MQJava) or put a loop on the get? (while there aren't any message try to get a message) Or does it make any difference?
I have seen both, and I guess what I am asking is if there is any reason that you would want to do the second. Is there any delay at all between the time that the message arrives and the time the message is processed if a wait interval is speicified?
gordon |
|
Back to top |
|
 |
bduncan |
Posted: Thu Nov 01, 2001 11:25 am Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
Imagine the following scenario. My application has an empty queue open. A message will arrive on this queue in 4 seconds. In the first case, my application issues an MQGET with a 5 second wait time. In the second scenario, it does an MQGET with no wait, and loops. Of course, the first case would still be wrapped in a loop, but it would only issue the MQGET every 5 seconds. The rate at which the second case loops depends on platform, language, and other factors (are you matching against CorrelId, etc...) but typically an MQGET on an empty queue will take very little time. So you could expect your application to loop several hundred times per second, perhaps more. The second approach obviously uses more resources than the first, and the queue manager is more taxed. Because of this, most people prefer to code their applications with wait intervals. As far as scenarios when the second approach is better, I can imagine an application where doing an MQGET and not getting a message (empty queue) is an important event, and processing needs to be done if this situation arises. Of course, if you do an MQGET with a long wait time, your application is blocked until the call returns so you can't do any of this processing. If my application was controlling some real-time system, and commands came in via MQSeries, it might be important for me to know immediately whethere there is a message waiting for me, and if not, execute some logic...
_________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|