Author |
Message
|
EricCox |
Posted: Tue Feb 10, 2015 10:35 am Post subject: Script Purging Messages from a Queue Based on MQMD.PutDateTi |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
To all,
I have a requirement to script a nightly autosys job to loop through all messages in a queue and purge each message that is more than 24hrs old.
What are the ways I can do this?
What is the easiest way to do this?
Thanks,
EMC |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 10, 2015 10:38 am Post subject: Re: Script Purging Messages from a Queue Based on MQMD.PutDa |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
EricCox wrote: |
I have a requirement to script a nightly autosys job to loop through all messages in a queue and purge each message that is more than 24hrs old.
What are the ways I can do this? |
Loop through all the messages in the queue and see if the put date & time is more than 24 hours in the past, using the programming language of your choice.
EricCox wrote: |
What is the easiest way to do this? |
Have the application putting the message set the expiry to 24 hours and eliminate the need to remove them with a separate process. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
bruce2359 |
Posted: Tue Feb 10, 2015 10:39 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
You could write a program that browses each message, looks at the create date/time in the MQMD; and for each message older than 24hrs, destructively consume those messages. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
PaulClarke |
Posted: Tue Feb 10, 2015 10:55 am Post subject: |
|
|
 Grand Master
Joined: 17 Nov 2005 Posts: 1002 Location: New Zealand
|
My SupportPac MO03 (QLOAD) can do this. You can select messages older or younger than a certain time and either remove them or move them to a different queue.
Cheers,
Paul _________________ Paul Clarke
MQGem Software
www.mqgem.com |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Feb 10, 2015 11:44 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
|
Back to top |
|
 |
EricCox |
Posted: Tue Feb 10, 2015 12:54 pm Post subject: QLOAD |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
For QLOAD I see I can use it to move a message to a file or another queue. I don't see an option for deleting or purging a message.
Do you see the switch to perform the delete?
Thanks |
|
Back to top |
|
 |
PaulClarke |
Posted: Tue Feb 10, 2015 1:06 pm Post subject: |
|
|
 Grand Master
Joined: 17 Nov 2005 Posts: 1002 Location: New Zealand
|
If I remember rightly there isn't really the notion of 'delete'. There is merely the notion of remove from queue and then you decide what you want to do with it.
So, suppose we want to remove all the message older than 1 hour from Q1 we could issue the following command
qload -IQ1 -f stdout -T1:0
Of course it is safer to put them to a queue so you can double check what you are deleting
qload -IQ1 -o OLDMESSAGEQUEUE -T1:0
However if you really don't want anything out then just put them to a NULL MQ Queue
qload -IQ1 -o NULLQ -T1:0
Where NULLQ is just a topic alias to an unused topic.
I do remember being asked to support the syntax -f NULL at one time but I don't believe I ever got around to is and, sadly, IBM won't allow me to continue to enhance QLOAD. Otherwise I would have put quite a few additions into it by now.
Cheers,
Paul. _________________ Paul Clarke
MQGem Software
www.mqgem.com |
|
Back to top |
|
 |
tczielke |
Posted: Tue Feb 10, 2015 1:32 pm Post subject: |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 Location: Illinois, USA
|
PaulClarke wrote: |
I do remember being asked to support the syntax -f NULL at one time |
Usually, there is a platform trick like "-f NUL" for Windows or "-f /dev/null" for Unix to discard data output that you don't care about. I would of thought the users would have just done that, but maybe there was something else they were getting at. |
|
Back to top |
|
 |
PaulClarke |
Posted: Tue Feb 10, 2015 1:35 pm Post subject: |
|
|
 Grand Master
Joined: 17 Nov 2005 Posts: 1002 Location: New Zealand
|
Yes that should work too although, as you say, it is platform (and environment) specific.
Cheers,
Paul. _________________ Paul Clarke
MQGem Software
www.mqgem.com |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Feb 11, 2015 2:03 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
PaulClarke |
Posted: Wed Feb 11, 2015 2:10 pm Post subject: |
|
|
 Grand Master
Joined: 17 Nov 2005 Posts: 1002 Location: New Zealand
|
Ha! Ok, they've made it public domain now have they?
Well, I guess anyone can enhance it now and I no longer have to field any questions about them. _________________ Paul Clarke
MQGem Software
www.mqgem.com |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Feb 11, 2015 2:13 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
PaulClarke wrote: |
I no longer have to field any questions about them. |
 |
|
Back to top |
|
 |
|