[rabbitmq-discuss] newbie question: message with delay

Tim Watson tim at rabbitmq.com
Mon Feb 11 23:06:29 GMT 2013


Hi Alex,

On 11 Feb 2013, at 11:41, Alex wrote:
> Hi!
> 
> I'm just getting into all this messaging systems. I'm wondering if it's possible to send message which will be processed after 24 hours from the current moment. Is there way to delay message processing? 
> I didn't found RabbitMQ documentation or mailing topic regarding this.
> 

Well you could put it in the queue and schedule the consumer to come online and dequeue it every 24 hours. If you really want to make the broker do this for you, then set up a queue with a per-message TTL of 24 hours. Put your messages into this queue and 24 hours after they were enqueued they will be removed. If you also set up a dead letter exchange then the 'expired' message will be dead lettered instead of deleted. You can bind another queue to the dead letter exchange and use this to consume messages that are 'ready' to be processed.

See http://www.rabbitmq.com/ttl.html and http://www.rabbitmq.com/dlx.html.

You should note, however, that the 24 hour thing will apply to *each message* and as I said the time will start from the moment the message is enqueued. So if you want to put 3 jobs in the queue and process them after 24, 48, 72 hrs, then this mechanism won't work for you. Personally I'd be more inclined to mark the messages as persistent and put them into a queue, then trigger the consumer to come online periodically using cron or if the consumer is long lived, using some programatic library.

Cheers,
Tim



More information about the rabbitmq-discuss mailing list