Author |
Message
|
elvis_gn |
Posted: Sat Jun 17, 2006 3:24 am Post subject: Escape an unlimited Get |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi guys,
I have a java app which waits on a queue for unlimited time to fetch messages based on matching correlId...This is working perfectly.
Now, over this i need to implement a timeout set by user...I am currently taking this interval and running a scheduled TimerTask...using the scheduled task, I am closing the queue and the QM connections...Even this is working.
The problem is that the get does not fail....it still keeps waiting on the queue and even picks a message when i put it...it only fails the second time.
Can I stop the get while in use or will I have to look for roundabouts ?
Regards. |
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Jun 17, 2006 5:11 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Yes, you can stop a Get with Unlimited Wait while it is in use.
You do this by putting a message on the queue that it will get.
If you want the Get to terminate on it's own, without a message, then don't use an unlimited wait.
You should know this stuff! _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
elvis_gn |
Posted: Sat Jun 17, 2006 10:59 pm Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi jefflowrey,
Just want to confirm that there is not simpler way out.
I did finally arrive at the two solutions that u suggested....also thought of something like making the get in a new thread and killing that on timeout....how does that sound ?
Or should i use the standard way of calulating the time left that i can wait on the queue...if i pick a message then calculate the time left for the second get...and so on...
Regards. |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun Jun 18, 2006 6:18 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Killing the thread should work, but it's a bad idea. It will leave things in an undecided state, and may leave the connection hanging.
I don't understand what you mean by "calculating the time left that you can wait".
In a request/response scenario, where you need to ensure that a response comes within a certain timeframe, you end up using a combination of get-with-wait and expiry. You set the expiry on the request to a certain period of time, and then you immediately do a get-with-wait for that same period of time. Then if the request comes back, you know it, and if it doesn't come back, you know it and nothing is really left hanging around afterwards.
If you have some different kind of timeout, where several operations need to occur within a specific timeframe... then, yes, you'll need to coordinate those operations and keep track of elapsed time... but I can't see why you'd even be using unlimited wait time for that in the first place. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
LuisFer |
Posted: Sun Jun 18, 2006 11:36 am Post subject: |
|
|
 Partisan
Joined: 17 Aug 2002 Posts: 302
|
Putting the get disabled of the Q, an app in a MQGET with waitinterval -1 exit the API with 2016.
Regards |
|
Back to top |
|
 |
kevinf2349 |
Posted: Sun Jun 18, 2006 12:01 pm Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
Luisfer
You are indeed correct but then something has to set the queue back to being get enabled.
Although given the awful design he is considering already he may just like this idea  |
|
Back to top |
|
 |
PeterPotkay |
Posted: Sun Jun 18, 2006 4:25 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
|
Back to top |
|
 |
LuisFer |
Posted: Sun Jun 18, 2006 5:18 pm Post subject: |
|
|
 Partisan
Joined: 17 Aug 2002 Posts: 302
|
kevinf2349 wrote: |
Luisfer
You are indeed correct but then something has to set the queue back to being get enabled.
Although given the awful design he is considering already he may just like this idea  |
My only intention is to help him.
Regards |
|
Back to top |
|
 |
elvis_gn |
Posted: Sun Jun 18, 2006 8:30 pm Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi guys,
[quote="LuisFer"]Putting the get disabled of the Q, an app in a MQGET with waitinterval -1 exit the API with 2016.
Regards
By disabled i guess u meant get inhibited....i tried that, but that only effects the second get that i try...the one is progress is not effected...
kevinf2349 wrote: |
Although given the awful design he is considering already he may just like this idea |
Hmm...ok i think i need to explain the scenario...I'm trying to develop a plugin node which would pick messages from a queue, similar to the MQGet node, ONLY that it would be capable of picking multiple messages, the number can be specified by the user, or the time to wait or even both together...
So now when i'm in the process of getting messages, incase the timeout occurs...what would be the best wy to close and leave...
And don't tell me that I should use aggregation ....this is a "learning in progress" so tell me a solution for this...
And jeff, by multiple gets i meant that i will go for the gets one by one, and wait for a time which will be the time specified by the user minus the time taken by previous gets...And i have implemented it, it seems to be working...
Regards. |
|
Back to top |
|
 |
|