Author |
Message
|
MarkDev |
Posted: Tue Jul 20, 2004 6:40 am Post subject: MQ Polling |
|
|
Newbie
Joined: 28 Jul 2003 Posts: 8
|
I am looking to write a program to poll a queue and process messages as they come in. Is there a standard way to do this? Any sample code out there? Any pitfalls to watch out for?
Thanks |
|
Back to top |
|
 |
gunter |
Posted: Tue Jul 20, 2004 7:19 am Post subject: |
|
|
Partisan
Joined: 21 Jan 2004 Posts: 307 Location: Germany, Frankfurt
|
There are many examples shipped with mq and in the repository on this site.
p.e. amqsget, amqsgetc, amqsbc, amqsbcg ( C )
You'll find also samples in C++, Java, Cobol, Perl... _________________ Gunter Jeschawitz
IBM Certified System Administrator - Websphere MQ, 5.3 |
|
Back to top |
|
 |
kirani |
Posted: Tue Jul 20, 2004 8:21 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Don't forget to use MQGMO_WAIT option which is better than polling the queue constantly. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
bower5932 |
Posted: Tue Jul 20, 2004 10:04 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
And don't forget the fail if quiescing option either. You'd like to break-out of your get if the qmgr is coming down. |
|
Back to top |
|
 |
kingsley |
Posted: Tue Jul 20, 2004 10:32 am Post subject: amqstrg0.c |
|
|
Disciple
Joined: 30 Sep 2001 Posts: 175 Location: Hursley
|
go through the program amqstrg0.c that comes with standard mq installation.
It is a code for client trigger monitor.
You will come to know how to code for polling, other basics like fail if quiescing , using different os while polling & others.
Best of luck
kingsley. |
|
Back to top |
|
 |
zpat |
Posted: Wed Jul 21, 2004 12:39 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
When I hear the words "MQ Polling" - I think Oh No - not again....
If you loop around in your application "polling" the queue - you will either have a high latency when messages arrive before they are processed (with a long wait) or a high MQI overhead (short waits).
As mentioned above - use the MQGMO WAIT option so that MQ "calls back" immediately on message arrival.
To retain some control in the application (eg for system closedown) make the wait a sensible value and repeat the request (eg a MQGMO WAIT interval of 60 seconds). If no message data then check for closedown and if not re-issue the MQGET and so on. |
|
Back to top |
|
 |
techno |
Posted: Tue Aug 31, 2004 9:45 pm Post subject: |
|
|
Chevalier
Joined: 22 Jan 2003 Posts: 429
|
Though I do not know exactly why it is needed, how about triggering being used in this context? |
|
Back to top |
|
 |
zpat |
Posted: Wed Sep 01, 2004 12:41 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Triggering is suitable when messages arrive relatively infrequently as the trigger monitor waits for you and dispatches your program on message arrival.
However it does cause extra MQ overhead (puts and gets on the init queue) and can also end up running more than one copy of the application if you are not careful.
I would say more than one message a second - don't trigger. Less than one message a minute, probably a good case for it. In between will depend on cirumstances, need more details. |
|
Back to top |
|
 |
|