Author |
Message
|
avivo22 |
Posted: Sun Apr 22, 2012 3:23 am Post subject: MqQueue.Get() "locked" when reading from multiple |
|
|
Newbie
Joined: 22 Apr 2012 Posts: 5
|
Hey,
i wrote java client that reads and processes messages from mq.
When i run multiple clients that read from the same queue, in each moment at least one of them is stuck for few seconds while trying to execute queue.get().
What can be the problem?
Here is my code:
Code: |
mqqueuemanager mgr=new mqqueuemanager(mgr-name);
Mqqueue queue = mgr.accessqueue(queue-name, mqconstants.mqoo_input_as_q_def);
Mqgetmessageoptions gmo=new mqgetmessageoptions();
Gmo.options=mqconstants.mqgmo_fail_if_quiseing | mqconstants.mqgmo_syncpoint;
While(true)
{
Mqmessage msg = new mqmessage();
System.out.println("before get");
Queue.get(msg)
system.out.println("after get");
//process message.....
mgr.commit();
}
|
Thanks,
Aviv |
|
Back to top |
|
 |
Vitor |
Posted: Sun Apr 22, 2012 4:49 am Post subject: Re: MqQueue.Get() "locked" when reading from multi |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
avivo22 wrote: |
What can be the problem? |
Almost anything. You've not said what version of the WMQ you're using, what environment you're running the Java under, how the queue manager is configured with particular reference to any consideration for multiple access. You've not even mentioned what OS you're using.
One point is that you're reading messages under syncpoint. If the messages are persistent and if you've got the logging and/or file system set up in a non-optimal way and/or you're running on a slow machine or the queue manager is using XA and the network is slow or the coordinator is slow then that could introduce a delay.
Or it could be 1 of a 100 different things. Perhaps if you gave a few more details (or some details) and what diagnostic steps you've taken. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
avivo22 |
Posted: Sun Apr 22, 2012 5:14 am Post subject: |
|
|
Newbie
Joined: 22 Apr 2012 Posts: 5
|
Sorry, im kind of new with mq.
I hope the following details will help you to diagnose my problom:
im using WMQ 7.0.1 installed on winServer 2008 R2 with 2GB memory dual core server.
My java app runs in linux (redhat).
Thanks,
Aviv |
|
Back to top |
|
 |
mqjeff |
Posted: Sun Apr 22, 2012 6:14 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You should also review the options on the queue that get populated when you use mqconstants.mqoo_input_as_q_def. |
|
Back to top |
|
 |
avivo22 |
Posted: Sun Apr 22, 2012 6:41 am Post subject: |
|
|
Newbie
Joined: 22 Apr 2012 Posts: 5
|
mqjeff wrote: |
You should also review the options on the queue that get populated when you use mqconstants.mqoo_input_as_q_def. |
the "default input open option" of the queue set to "input shared". |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Apr 22, 2012 10:13 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
it could also be something completely outside of your specific app but that impacts the qmgr. Are you making extensive use (not in your app but in others) of dynamic temporary queues? What is the message size when this happens. Is it significantly bigger than the average message?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rekarm01 |
Posted: Sun Apr 22, 2012 3:12 pm Post subject: Re: MqQueue.Get() "locked" when reading from multi |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
avivo22 wrote: |
When i run multiple clients that read from the same queue, in each moment at least one of them is stuck for few seconds while trying to execute queue.get().
What can be the problem? |
The posted code has syntax errors and spelling errors, so there are at least some discrepancies with the code that's actually running. There could be a delay in the running code that's not posted; it's difficult to help with that.
One obvious guess: if the queue is empty and the client enables a wait interval, then the get will block, waiting for the next message.
How is the delay actually measured? If the output stream is buffered, (particularly if it's redirected to a file or piped to some other command), then the apparent delay could be due to the buffering. It might be useful to use System.currentTimeMillis() or similar method to more accurately calculate the elapsed before and after the get. |
|
Back to top |
|
 |
avivo22 |
Posted: Sun Apr 22, 2012 10:39 pm Post subject: |
|
|
Newbie
Joined: 22 Apr 2012 Posts: 5
|
fjb_saper wrote: |
it could also be something completely outside of your specific app but that impacts the qmgr. Are you making extensive use (not in your app but in others) of dynamic temporary queues? What is the message size when this happens. Is it significantly bigger than the average message?  |
The answers is No  |
|
Back to top |
|
 |
avivo22 |
Posted: Sun Apr 22, 2012 10:46 pm Post subject: Re: MqQueue.Get() "locked" when reading from multi |
|
|
Newbie
Joined: 22 Apr 2012 Posts: 5
|
rekarm01 wrote: |
avivo22 wrote: |
When i run multiple clients that read from the same queue, in each moment at least one of them is stuck for few seconds while trying to execute queue.get().
What can be the problem? |
The posted code has syntax errors and spelling errors, so there are at least some discrepancies with the code that's actually running. There could be a delay in the running code that's not posted; it's difficult to help with that.
One obvious guess: if the queue is empty and the client enables a wait interval, then the get will block, waiting for the next message.
How is the delay actually measured? If the output stream is buffered, (particularly if it's redirected to a file or piped to some other command), then the apparent delay could be due to the buffering. It might be useful to use System.currentTimeMillis() or similar method to more accurately calculate the elapsed before and after the get. |
This is not the same code, just the idea...the code compiles&run perfect without errors/warnings.
The queue isnt empty. I put 5000 messages in the queue and then start my 3 clients at the same time and i can clearly see "locks" when 2 clients are showing "trying to get message" while the third client reads a lot of messages at the same time.
sometimes there are 2 "active clients" and just one "locked". |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 23, 2012 4:45 am Post subject: Re: MqQueue.Get() "locked" when reading from multi |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
avivo22 wrote: |
This is not the same code, just the idea...the code compiles&run perfect without errors/warnings. |
If I'd been allowed to consider code error free when it compiled clean, I'd have got through a lot more COBOL back in the day....
The fact that it compiles and doesn't throw errors doesn't mean the code doesn't have problems.
avivo22 wrote: |
i can clearly see "locks" when 2 clients are showing "trying to get message" while the third client reads a lot of messages at the same time. |
How do you see this? Where? Is it your code generating this or some kind of Java container?
As I & others have said, this could be nothing to do with your code but a queue manager configuration issue. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Apr 23, 2012 4:58 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It could also be as simple as trying to use the same connection to execute multiple gets. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 23, 2012 5:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
It could also be as simple as trying to use the same connection to execute multiple gets. |
Without the actual code who can say?
Without knowing where these "locks" are being "seen" who can say? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Apr 23, 2012 4:55 pm Post subject: Re: MqQueue.Get() "locked" when reading from multi |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
avivo22 wrote: |
The queue isnt empty. I put 5000 messages in the queue and then start my 3 clients at the same time and i can clearly see "locks" when 2 clients are showing "trying to get message" while the third client reads a lot of messages at the same time.
sometimes there are 2 "active clients" and just one "locked". |
Sounds like a know problem to me. Upgrade!
What version of WMQ are you on!  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|