|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Polling for msg's on Q by multiple threads |
« View previous topic :: View next topic » |
Author |
Message
|
yaravind |
Posted: Wed Jan 22, 2003 1:25 pm Post subject: Polling for msg's on Q by multiple threads |
|
|
Apprentice
Joined: 17 Jun 2002 Posts: 25
|
Hi,
By design, I have to use more than one thread for polling the Q for messages. I am unable to provide solution for the following scenario
T- Thread
T1, T2 and T3 are polling for messages on a particluar Q (getCurrentDepth()>0)
all the three threads get a depth greater than 0
T1 is now active and tries GETs the message
T1 is suspended
T2 noe GETs the message
T1 is resumed
T1 now tries to get the message and results in exception
Pls help me in resolving this situation
Can I solve this situation by opening the Q in READ-EXCLUSIVE mode?
Thanks in advance. |
|
Back to top |
|
 |
nimconsult |
Posted: Sun Jan 26, 2003 11:45 pm Post subject: |
|
|
 Master
Joined: 22 May 2002 Posts: 268 Location: NIMCONSULT - Belgium
|
It is a frequent but very bad habit to use the GetCurrentDepth() method to achieve your purpose.
Using exclusive mode does not conform to your requirement of having 3 concurrent consumers.
What you should do is combine wait and get by calling MQGET with the MQGMO_WAIT option. Your application code should look something like:
while true
get message with wait (either limited or unlimited wait interval)
process message
loop
catch exception when message not found
the loop ends do whatever you want
Nicolas _________________ Nicolas Maréchal
Senior Architect - Partner
NIMCONSULT Software Architecture Services (Belgium)
http://www.nimconsult.be |
|
Back to top |
|
 |
yaravind |
Posted: Mon Jan 27, 2003 6:20 am Post subject: thanks for the logic. |
|
|
Apprentice
Joined: 17 Jun 2002 Posts: 25
|
thanks for the logic.
Lets say I coded the bean using ur logic. In our production environment the bean will be deployed in a cluster of four application server instances. I want to know what will happen if there are four concurrent requests and only one messages on tge queue.
1) what r the chances of more than one thread (bean) receiving the message
Thanks in advance. |
|
Back to top |
|
 |
zpat |
Posted: Mon Jan 27, 2003 6:44 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
I've seen major performance problems caused by a vendor who totally failed to grasp the concept of MQ Event driven design and ended up polling the queue (MQGET) ten times a second!
This is especially bad if an MQ CLIENT design is invoved as it means network traffic since all MQI calls are transported to the MQ SERVER synchronously.
You should never poll a queue in the sense of going a MQGET - waiting in your application and repeating this.
The reason is that you will cause excessive MQI overhead and also a latency if a message arrived while YOUR thread is waiting.
Instead, simply issue MQGET with WAIT - and MQSeries will wait for you and immediately resume when a message is available.
You should use a MQGET WAIT interval of perhaps 60 seconds and then repeat this, if you want to occasionally check for your own application being closed down.
Don't forget to add FAIL_IF_QUIESCING to the MQGET options as well.
----
As for multiple threads, they can all MQGET WAIT on the same queue if need be, they will automatically load balance if multiple messages arrive as they "compete" for incoming messages. I believe MQSeries will pass the next message to the thread that issued the MQGET first.
A single message will only to be passed to one thread that has an outstanding MQGET WAIT, the others will continue to wait until another message is available for them. There is no chance of the same message being passed to more than one thread. |
|
Back to top |
|
 |
yaravind |
Posted: Mon Jan 27, 2003 8:38 am Post subject: |
|
|
Apprentice
Joined: 17 Jun 2002 Posts: 25
|
|
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
|
|
|
|