Author |
Message
|
Umeshrath |
Posted: Wed Apr 26, 2006 10:30 am Post subject: need opinion on MQ program. |
|
|
Novice
Joined: 27 Dec 2005 Posts: 23 Location: Hyderabad
|
Hi All,
My requirement is to drain a queue based on certain condition in batch enviornment.
Read a record.
If value = a then delete that record from the queue else dont delete the record.
What i have thought of?
ØFirst i will do an MQ enquire to know the current depth.
ØIf the current depth is “N “ then we will do MQGET “N “ times.
Ø If the condition satisfied then do nothing else
write the record to the queue.
I want opinion about this logic.
If anybody have better idea than this then please share it with me.
Regards,
Umesh _________________ Umesh Rath |
|
Back to top |
|
 |
wschutz |
Posted: Wed Apr 26, 2006 10:45 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Well.. first, you can't trust CURDEPTH to predict how many message your program will be able to MQGET. The reason for this have been explained here in MQSeries.net.
So you want to remove messages if they meet a certain requirement? A better model would be to BROWSE the messages and then if you want to remove the message use MQGMO_MSG_UNDER_CURSOR. You can BROWSE the queue until you've processed all the messages, _________________ -wayne |
|
Back to top |
|
 |
Umeshrath |
Posted: Thu Apr 27, 2006 6:16 am Post subject: |
|
|
Novice
Joined: 27 Dec 2005 Posts: 23 Location: Hyderabad
|
can you throw some more light on MQGMO_MSG_UNDER_CURSOR.
What i understand from that i will first do MQGET with browse option and then when ever my condition will be met then i will do a destructive MQ get.
But i think by this method the cursor position will be lost.
Please elaborate on this approach.
Thanks a lot.
Regards,
Umesh _________________ Umesh Rath |
|
Back to top |
|
 |
PeterPotkay |
Posted: Thu Apr 27, 2006 6:21 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
|
Back to top |
|
 |
Vitor |
Posted: Thu Apr 27, 2006 6:29 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Here's a clue - in the link PeterPotkay sent, you should be looking in and around where it says this:
Quote: |
The MQGMO_MSG_UNDER_CURSOR option can subsequently be used with a nonbrowse MQGET call if required, to remove the message from the queue.
The browse cursor is not moved by a nonbrowse MQGET call using the same Hobj handle. Nor is it moved by a browse MQGET call that returns a completion code of MQCC_FAILED, or a reason code of MQRC_TRUNCATED_MSG_FAILED.
|
I'm interesting in the design of your code. You've got a queue where you're reading through it, looking for a particular condition in the data, destructively reading all those messages which conform to the condition and leaving all those that don't. What reads off all the other messages? Is it another similar application? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
wschutz |
Posted: Thu Apr 27, 2006 6:57 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Umeshrath wrote: |
But i think by this method the cursor position will be lost. |
No, doing the destructive GET does not loose the browse cursor. _________________ -wayne |
|
Back to top |
|
 |
Umeshrath |
Posted: Thu Apr 27, 2006 9:01 am Post subject: |
|
|
Novice
Joined: 27 Dec 2005 Posts: 23 Location: Hyderabad
|
Hi All,
My requirement is that if the records are more than 24 hours old then delete that record from the queue else dont do anything. _________________ Umesh Rath |
|
Back to top |
|
 |
vennela |
Posted: Thu Apr 27, 2006 9:31 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Then why not set the expiry on the message? |
|
Back to top |
|
 |
Umeshrath |
Posted: Thu Apr 27, 2006 9:45 am Post subject: |
|
|
Novice
Joined: 27 Dec 2005 Posts: 23 Location: Hyderabad
|
Is there any method to set the expiry time for the message?
Is this the job of the administartor or we can do something programatically?
Expiry date means the record will be automatically deleted after 24 hours it got written into the queue.
Please confirm.
Regards,
Umesh _________________ Umesh Rath |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Apr 27, 2006 9:57 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Expiration is set by the program on the message.
Messages that have expired are removed by the qmgr at various points in time - the only guarantee given is that no application will ever GET an expired message. On z/OS there are processes that will periodically scan queues and remove expired messages. On other platforms, the behavior is more dependent on version. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Umeshrath |
Posted: Thu Apr 27, 2006 6:47 pm Post subject: |
|
|
Novice
Joined: 27 Dec 2005 Posts: 23 Location: Hyderabad
|
Hi Jeff,
Can u just throw some more light how to set the expiry time for a message programmatically? If u have some sample code then that will help a lot.
Thnaks a lot.
Regards,
Umesh _________________ Umesh Rath |
|
Back to top |
|
 |
kevinf2349 |
Posted: Thu Apr 27, 2006 7:01 pm Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
Read the Application Programming Reference manual. It is clearly documented in there.
You will learn best from doing things yourself. You aren't Jeevan are you?  |
|
Back to top |
|
 |
Vitor |
Posted: Thu Apr 27, 2006 10:53 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Using expiry also allows you to be far more flexible; expiry times can be set to different values according to message. Maybe not a requirement not, but as soon as someone finds out messages go automatically after 24 hours their message will need to be deleted sooner or later than that.
Also removes all the scheduling problems from your program (when to run it, what to do if it fails, etc, etc) and bungs it all onto the queue manager. Where it belongs.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|