Author |
Message
|
akidase |
Posted: Mon Mar 26, 2012 4:18 am Post subject: How to delete messages from a queue based on date |
|
|
Centurion
Joined: 10 Jan 2011 Posts: 124
|
|
Back to top |
|
 |
Vitor |
Posted: Mon Mar 26, 2012 4:37 am Post subject: Re: How to delete messages from a queue based on date |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
akidase wrote: |
Is it possible that we will be able to delete messages from a queue, based on date ? I am planning to have a cron job for the same. |
It's considered best practice, if a message has a given lifespan, to have that lifespan set by the sender as the expiry. Using this, the queue manager will clean up without intervention.
There isn't a command to remove messages by date. Some support pacs have this facility, and it's a trivial task to adapt one of the samples to do this.
But I still recommend expiry. No additional components and much greater flexibility on lifespan. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
akidase |
Posted: Mon Mar 26, 2012 5:32 am Post subject: |
|
|
Centurion
Joined: 10 Jan 2011 Posts: 124
|
Quote: |
I still recommend expiry. |
That was my first option too.. But our requirement is to clear messages based on date. Since we are clearing backed out messages, we want to provide some time for application teams to see thro' them , for a stipulated time.
Quote: |
Some support pacs have this facility, and it's a trivial task to adapt one of the samples to do this. |
Could you please provide me with any link, which serves as an example to do this? |
|
Back to top |
|
 |
Vitor |
Posted: Mon Mar 26, 2012 5:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
akidase wrote: |
Could you please provide me with any link, which serves as an example to do this? |
amqsget, q, qload, etc, etc, etc. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
bruce2359 |
Posted: Mon Mar 26, 2012 6:23 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
A samples directory is installed when you install WMQ. Amsget sample application should provide an app developer with skeleton source code.
The sample code needs to be modified to look at the date/time fields of the MQMD, to then decide whether to destructively consume the message (old/expired), or leave it in the queue. _________________ 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 |
|
 |
md7 |
Posted: Mon Mar 26, 2012 3:17 pm Post subject: |
|
|
 Apprentice
Joined: 29 Feb 2012 Posts: 49 Location: Sydney.AU
|
I did this before with QLoad (MO03). Moved all messages older than a certain date into a TEMP queue, double checked the dates it then emptied it |
|
Back to top |
|
 |
akidase |
Posted: Mon Mar 26, 2012 10:45 pm Post subject: |
|
|
Centurion
Joined: 10 Jan 2011 Posts: 124
|
Quote: |
I did this before with QLoad (MO03). |
That worked for me as well. Thanks!
Quote: |
A samples directory is installed when you install WMQ. |
I have installed MQ7.0 in Windows 7 System. I am not sure of the directory where it is present.
I remember previous versions having it at C:\Program Files (x86)\IBM\WebSphere MQ\tools.But this one doesn't ve.
Quote: |
amqsget, q, qload, etc, etc, etc. |
Thank you Vitor. |
|
Back to top |
|
 |
zpat |
Posted: Mon Mar 26, 2012 11:41 pm Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
MA01 (queue program) can also do this kind of thing, arguably more suitable than MO03 (although both are by the same author). |
|
Back to top |
|
 |
akidase |
Posted: Tue Mar 27, 2012 3:19 am Post subject: |
|
|
Centurion
Joined: 10 Jan 2011 Posts: 124
|
Vitor and all,
I need to implement 'em, for backed out messages.
If I set the expiry to incoming message, can I be assured that same headers will be present for the backed out message? |
|
Back to top |
|
 |
bruce2359 |
Posted: Tue Mar 27, 2012 4:25 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
akidase wrote: |
Vitor and all,
I need to implement 'em, for backed out messages.
If I set the expiry to incoming message, can I be assured that same headers will be present for the backed out message? |
What is 'em?
Messages are backed out by applications; and it is applications that manipulate MQMD and other headers. _________________ 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 |
|
 |
mqjeff |
Posted: Tue Mar 27, 2012 4:52 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Several IBM products will automatically back out messages for you, and these will make sure that the expiry is still set on the message. For example, MQ's JMS provider and Message Broker.
The base MQ API does not provide a function to automatically back out messages. It merely provides functions to identify when a message should be backed out and where to put it. It is then up to each application to decide how it handles this information.
So you won't know if the message headers and expiry will be honored unless you know the application that is doing the backout.
As always, it is a significantly better idea to TRY this BEFORE you ASK. It wastes less of your time, and you can rely on the answer much more. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 27, 2012 8:33 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
akidase wrote: |
... That was my first option too.. But our requirement is to clear messages based on date. Since we are clearing backed out messages, we want to provide some time for application teams to see thro' them , for a stipulated time. |
If it is not the responsibility of the application's admins to review the errors and fix the messages and deal with them, why would you want to send them in the first place? Just build an application that does not work and delete the messages every day???  _________________ MQ & Broker admin |
|
Back to top |
|
 |
yeyeman9 |
Posted: Mon Aug 20, 2012 12:48 pm Post subject: |
|
|
Newbie
Joined: 20 Aug 2012 Posts: 2
|
Hi,
I am curious...is there anyway to do this without the need of installing a support package?
For example, what we wish to accomplish is remove a message after X amount of time.
Any code line we can apply in the Manager to get this done?
Expiry seems like a good idea except we don't want to have to get it done for each message, instead we would like to have a "General" place where this order of "after X amount of time, remove from queue" is done. Which is why we would like to do it in the manager.
Any ideas?
Appreciate the time and help! |
|
Back to top |
|
 |
bruce2359 |
Posted: Mon Aug 20, 2012 1:05 pm Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
Have you read the replies to this post?
There is no such queue-manager setting. _________________ 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 |
|
 |
yeyeman9 |
Posted: Mon Aug 20, 2012 1:15 pm Post subject: |
|
|
Newbie
Joined: 20 Aug 2012 Posts: 2
|
bruce2359 wrote: |
Have you read the replies to this post?
There is no such queue-manager setting. |
Well I saw that there is not one command that does that. But I am guessing then that there is no possible combination to get this done then? WE can only do it with a Support pack?
Thanks for the quick answer by the way. |
|
Back to top |
|
 |
|