Author |
Message
|
vatsanc |
Posted: Fri Sep 08, 2006 2:00 pm Post subject: How to delay the delivery of messages in MQ |
|
|
Newbie
Joined: 27 Jun 2006 Posts: 6
|
Is there a way in Websphere MQ - either on the server side or in the API - to set a time delay in delivery of messages put on a queue ? The business requirement is as follows:
There are 2 tiers of customers: tier-1 and tier2. Every customer has a dedicated queue. The tier-1 customers get the messages immediately after the message is put on their queues. The tier-2 customers are beta customers that should get the message after a delay. Its the same application that puts the message out on all the queues. Whats the most elegant way to implement this delayed delivery requirement ?
Thanks |
|
Back to top |
|
 |
wschutz |
Posted: Fri Sep 08, 2006 2:49 pm Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Well, there is no way to delay putting a message on a queue, but you can delay taking messages off queues.... how were you planning on servicing T1 customers? Triggering? _________________ -wayne |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 08, 2006 2:56 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
There are several bad ways of accomplishing what you want.
One is to implement logic in your code that delays committing messages intended for tier-2 customers. This will fairly rapidly fill up both your uncomitted message count, AND your log files. So it's quite a beaut.
Another is to misuse expiry, and expiry-report-with-full-data. If you put all yoru tier2 messages to a queue that is only browsed, with a suitable expiration time on the messages, then when the message expires, a different copy will get put onto the "replytoqueue" of the message - which could be your tier2 partner's input queue. Then they'd have to be prepared to receive messages that were Report messages, rather than Datagrams.
A third way is to edit the mirrorq API exit, or some other API exit, such that it can tell if a message belongs to tier1 or tier2 and will "delay" it if it belongs to tier2.
A fourth way is to misuse message priority, and some kind of intermediary queue that has a process that will immediately forward high priority messages in favor of low priority messages. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
scooper750 |
Posted: Thu Sep 21, 2006 4:04 am Post subject: Question |
|
|
Newbie
Joined: 20 Sep 2006 Posts: 2
|
Jeff, have a question about the misuse of expiry in particular. Are you using the setJMSExpiry... or setTimeToLive. I've actually tried both with no luck. In my case, setJMSExpiration had no effect (as expected according to the documentation). Expiry set to 0 for unlimited when I look at the messages in the queue. As for timeToLive, that worked as far as removing the message from the queue when the timeToLive expires, but it never sends a reply to the queue that I specified in setJMSReplyTo.
Basically, for my scenario this is what I need.
I've got messages being put on Queue 1 that is being picked up by an MDB and processed. While processing if resources are unavailable (on the host in my case - VSAM files, etc), I want to take that input object to the Queue 1 MDB, place it on Queue B (which is read only and has no consumers) with an expiry and a replyTo of Queue 1 so that the input will retry in X hrs or minutes. Theoretically should work great, but I must be missing something.
The EJB 2.1 spec has exactly what I need (TimerService), but since we're running EJB 2.0 i'm S.O.L. Any input would be appreciated.
Last edited by scooper750 on Thu Sep 21, 2006 4:16 am; edited 1 time in total |
|
Back to top |
|
 |
wschutz |
Posted: Thu Sep 21, 2006 4:14 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Did you set:
MQRO_EXPIRATION or
MQRO_EXPIRATION_WITH_DATA or
MQRO_EXPIRATION_WITH_FULL_DATA
also, you do not that report messages are only produced when the message expires... which might not be exactly when you think it should be .... _________________ -wayne |
|
Back to top |
|
 |
scooper750 |
Posted: Thu Sep 21, 2006 4:21 am Post subject: |
|
|
Newbie
Joined: 20 Sep 2006 Posts: 2
|
I didn't see any methods that would set that. Is that an option on the message level or on the QueueSender level. Using javax.jms.ObjectMessage and javax.jms.QueueSender. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Sep 21, 2006 4:28 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
bruce2359 |
Posted: Fri Sep 22, 2006 6:47 am Post subject: |
|
|
Guest
|
Is there anything in the application data portion of the message that identifies it as tier1 or tier2? (Or can the putting application insert tierx in an unused field in the MD?)
Since put time is in the MQMD, your application could get the message, look at the tierx and put time; then suspend itself (wait) for whatever period of time you want.
This method would have little impact on MQ's workload. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 22, 2006 6:52 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Bruce, yes. That's a good way of solving this problem.
But it's not in the MQ API or the Server configuration, as the original poster asked about. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
chv_v |
Posted: Sat Sep 23, 2006 12:45 pm Post subject: |
|
|
Newbie
Joined: 01 Feb 2005 Posts: 9
|
How can we delay taking messages off from queues.
I am working on Broker V5
thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Sep 23, 2006 2:46 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
chv_v wrote: |
How can we delay taking messages off from queues.
I am working on Broker V5
thanks |
You can't in Broker v5.
Not at a per-message level, at least.
In v6, you could wire in some Timeout* nodes and maybe an MQGet. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Sep 23, 2006 10:34 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
chv_v wrote: |
How can we delay taking messages off from queues.
I am working on Broker V5
thanks |
And as mentioned previously unless you are under some imperative you cannot change, challenge the design. Messages are built to flow. Trying to delay them is against the patterns and design. _________________ MQ & Broker admin |
|
Back to top |
|
 |
|