Author |
Message
|
hargitt |
Posted: Thu Nov 03, 2005 3:31 am Post subject: Scheduling message delivery |
|
|
Newbie
Joined: 03 Nov 2005 Posts: 5
|
Is there a way to schedule the delivery of a message? For example, can you insert a message in a queue and have the consumer only pick it out exactly 2 hours after is was inserted?
I have searched around and I have not found any selector variable that can indicate the current time.
I was thinking of a selector like:
JMSTimestamp <currentTimeMillis - 60000
where currentTimeMillis is a variable replaced by the current system time in miliseconds (i.e. like sysdate in Oracle). In this example, the selector would schedule delivery of every message to consumers one minute after the message has been inserted in the queue.
Is there such a variable as currentTimeMillis? If not, I have to continually recreate the selector and update currentTimeMillis!
Maybe I am taking the wrong approach? |
|
Back to top |
|
 |
Mr Butcher |
Posted: Thu Nov 03, 2005 5:27 am Post subject: |
|
|
 Padawan
Joined: 23 May 2005 Posts: 1716
|
i do not know about jms selectors...... but there is no message scheduling in mqseries. once a message is given to mqseries, mq tries to deliver it. if the message is delivered and has reached its final destination, it is available for get.
the only thing that comes into my mind is - when using distributed queueing - to give the data to mqseries and have the channel stopped so the data is not delivered to other queuemanagers until the channel is started, but that is a really bad design. kids, dont try that at home! mq is no data store!
maybe the best thing is to schedule the program that puts the data to mqseries. _________________ Regards, Butcher |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 03, 2005 5:28 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Totally wrong approach.
What are you trying to achieve? Why the delay? |
|
Back to top |
|
 |
hargitt |
Posted: Thu Nov 03, 2005 6:06 am Post subject: |
|
|
Newbie
Joined: 03 Nov 2005 Posts: 5
|
I need to implement the delay because the external system that provides me the message (I insert the message in the queue) can not deal with such a quick response.
Actually, we are processing messages that come from a mobile network. These are SMS messages. When a mobile phone sends an SMS to our system and requests a delivery receipt from the operator, the delivery receipt is returned to the mobile phone at the same time as we reply to the user's message.
A mobile phone can not receive two messages at the same time thus one of the two have to be delayed. By default, an operator will in average delay the second message anywhere from 5 to 15 minutes. Unfortunatly the delivery receipt is always the first message to reach the phone, thus users get back our reply with much delay. The experience for the user is like waiting 5 minutes for a web page to return... not very nice...
The simplest thing I can think of for creating a delay is via the JMS queues we use to queue incoming and outgoing traffic. If we can make sure each message inserted in the incoming queue only gets delivered to the consumer after 2-3 seconds, we will avoid the problem on the user's mobile phone.
A sleep is definatly not a solution as we may easily be processing 50 messages per second on average. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 03, 2005 6:26 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You should use a database table for this.
In the following manner,
1) an SMS message arrives on your queue
2) Insert it into the database with the current timestamp
3) Select all messages older than 5 seconds from the database
4) send those messages in oldest first order
5) wait for the next message on your queue _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
hargitt |
Posted: Thu Nov 03, 2005 6:33 am Post subject: |
|
|
Newbie
Joined: 03 Nov 2005 Posts: 5
|
meaning that there is no JMS solution for this? |
|
Back to top |
|
 |
bower5932 |
Posted: Thu Nov 03, 2005 7:14 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
You can certainly use JMS for steps 1, 4, 5 from Jeff's append. |
|
Back to top |
|
 |
wschutz |
Posted: Thu Nov 03, 2005 7:55 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
If you have MQ Brover V6 in the mix, you can easily use the new Timeout nodes to accomplish this.  _________________ -wayne |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 03, 2005 7:59 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
wschutz wrote: |
If you have MQ Brover V6 in the mix, you can easily use the new Timeout nodes to accomplish this.  |
But it is certainly not worth buing and installing Broker v6 JUST for the timeout nodes. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
hargitt |
Posted: Fri Nov 04, 2005 2:13 am Post subject: |
|
|
Newbie
Joined: 03 Nov 2005 Posts: 5
|
So I guess a JMS wish list for the selector is a CURRENT_TIME variable...
Safer to have a home made DB queue with a select that only pulls out messages that are older than x seconds. |
|
Back to top |
|
 |
slm.ismail |
Posted: Sun May 21, 2006 7:31 am Post subject: Scheduling MQ Series Messages |
|
|
Newbie
Joined: 21 May 2006 Posts: 3
|
Mr, Hergitt..
have you resolved the above mentioned issue? ( scheduling x mins to delivering the msgs ) ? |
|
Back to top |
|
 |
hargitt |
Posted: Sun May 21, 2006 11:52 pm Post subject: |
|
|
Newbie
Joined: 03 Nov 2005 Posts: 5
|
No.
I ended up using JBossMQ. They have a "non-standard" solution allowing you to set the delivery time of the message.
Example:
jmsMsg.setLongProperty("JMS_JBOSS_SCHEDULED_DELIVERY", message.getSendTime()); |
|
Back to top |
|
 |
|