Author |
Message
|
team |
Posted: Thu Jun 21, 2007 8:31 am Post subject: Multiple Connects |
|
|
Centurion
Joined: 03 Nov 2006 Posts: 108
|
Please could you let me know of the performance implications of issuing mulitple connects on the Queuee Manager.
The background for this is:
I need to run a process to continuously poll a queue for messages. This process is triggered once in a day.
Which would be a better option
1) When the process is triggered, I open a queue and perform get operations on them every minute(say that is the time-check required)
OR
2) Every minute i should connect-get-disconnect.
Ideally i would imagine the first option to be good, but is there a limit for the connection to last. Since it will open once in a day and close at the end of the day.
Please could you advise.
Thanks in advance |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Thu Jun 21, 2007 8:47 am Post subject: Re: Multiple Connects |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
These two options depends on queue workload.
- How often will you see new message in queue ?
- Will it be business hours lets say between 8.00 and 20.00 ? _________________ Marcin |
|
Back to top |
|
 |
zpat |
Posted: Thu Jun 21, 2007 9:59 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
What's wrong with using MQGET with WAIT?
Never repeatedly "poll" a queue, it's entirely the wrong design concept especially for MQ client connections. |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Thu Jun 21, 2007 10:31 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
zpat wrote: |
What's wrong with using MQGET with WAIT?
Never repeatedly "poll" a queue, it's entirely the wrong design concept especially for MQ client connections. |
I don't get it.
Why is it wrong design concept ?
Even you use MQGET with WAIT you should do it in loop. You don't set WAIT to unlimited.
connect - > get -> disconnect (especially every minute) is usually wrong design concept (there are exceptions)
Repeatedly "poll" a queue is rather standard.
... or maybe my understanding of repeatedly "poll" a queue is different. _________________ Marcin
Last edited by marcin.kasinski on Thu Jun 21, 2007 10:46 am; edited 1 time in total |
|
Back to top |
|
 |
zpat |
Posted: Thu Jun 21, 2007 10:43 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
I would set the MQGMO_WAIT to at least 60 seconds. This is only the max wait time and not the minimum. When a suitable message arrives the queue manager will immediately end the wait.
Why not use unlimited? If the queue manager is closing the FAIL_IF_QUIESCING option applies.
If you poll (and wait in your own code), then you either incur latency (since you can be waiting when a message arrives) or you incur overhead (frequent calls to the queue manager to reduce latency).
You simply must get one or the other. Neither is a good thing.
If you don't really care about latency (delay in processing messages) then polling once a minute is OK.
But it's still better not to connect or open the queue each time (keep the queue open). |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jun 21, 2007 10:50 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It doesn't matter how long you set the WAIT for, you still have to loop over the MQGET. And that's polling.
However, one does want to limit the number of times one connects and disconnects from the qmgr, and one does want to limit the number of times one opens or closes a queue.
So one should set a reasonably large WAIT, build the program to read the queue until no messages are left, and only connect and disconnect at program start or shutdown. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
team |
Posted: Thu Jun 21, 2007 2:43 pm Post subject: |
|
|
Centurion
Joined: 03 Nov 2006 Posts: 108
|
Hi...
But do you see any problems in keeping a connection open the whole day?
Thnaks |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jun 21, 2007 5:40 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Why would the connection be open all day?
Your program will start when it's triggered - which you've said is once a day.
It will process all messages on the queue until the queue is empty.
Your program will then end, closing the connection.
The Next Day, your program will be triggered again.
That's the requirement you've laid out, yes? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
team |
Posted: Fri Jun 22, 2007 12:14 am Post subject: |
|
|
Centurion
Joined: 03 Nov 2006 Posts: 108
|
The program needs to trigger to check for messages on the queue every minute. If a message is found, then get and process the message.
Hence, every minute it would poll...in the sense..connect->get. |
|
Back to top |
|
 |
zpat |
Posted: Fri Jun 22, 2007 1:35 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
No it's doesn't need to. That's your design. We have suggested better ones but if you can't distinguish between requirements and implementation options we are wasting our time here. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jun 22, 2007 2:01 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
team wrote: |
The program needs to trigger to check for messages on the queue every minute |
No it doesn't. Use the method zpat has suggested. For the reasons outlined.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jun 22, 2007 2:52 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Last but not least if your distribution is discrete (you only get a message once in a while) and you are not running in a J2EE environment (no EJBs) you might want to run as a triggered program ...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 22, 2007 3:26 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You said your program would be triggered once a day.
Now you say it needs to read messages all day.
These are entirely different behaviors.
There's nothing wrong with writing an MQ program that will run all day, every day, and keep the MQ connection open all day every day. You should program in a number of options to ensure that the MQ administrator can do what needs to be done, though.
It's a bad idea to write a program that will open up a connection once a minute, and then close it again.
Depending on how OFTEN messages will show up in the queue, you can either use a purely triggered program - which will get started when a message appears on the queue, and end when the queue is empty - or you can use a listener-style program, which will get started once and use a WAIT timeout to get messages when there are messages. Or you can use a mixed program, that will get triggered, but hang around listening to the queue for a while after the queue is empty.
The Application Programming Guide is a valuable read, and is worth your time. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|