Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple scalable work/message queue with delay

I need to set up a job/message queue with the option to set a delay for the task so that it's not picked up immediately by a free worker, but after a certain time (can vary from task to task). I looked into a couple of linux queue solutions (rabbitmq, gearman, memcacheq), but none of them seem to offer this feature out of the box.

Any ideas on how I could achieve this?

Thanks!

like image 963
idevelop Avatar asked Mar 02 '10 15:03

idevelop


People also ask

How do I send a delayed message with SQS?

To set delay seconds on individual messages, rather than on an entire queue, use message timers to allow Amazon SQS to use the message timer's DelaySeconds value instead of the delay queue's DelaySeconds value. To use the Amazon Web Services Documentation, Javascript must be enabled.

How do I add a delay in RabbitMQ?

To delay a message, the user must publish it with the x-delay header, which accepts an integer representing the number of milliseconds the message should be delayed by RabbitMQ. It's worth noting that delay in this context means delaying message routing to queues or other exchanges.

What is a poison pill AWS?

Poison pills are special messages that can be received, but not processed. They are a mechanism used in order to signal a consumer to end its work so it is no longer waiting for new inputs, and is similar to closing a socket in a client/server model.


1 Answers

I've used BeanstalkD to great effect, using the delay option on inserting a new job to wait several seconds till the item becomes available to be reserved.

If you are doing longer-term delays (more than say 30 seconds), or the jobs are somewhat important to perform (abeit later), then it also has a binary logging system so that any daemon crash would still have a record of the job. That said, I've put hundreds of thousands of live jobs through Beanstalkd instances and the workers that I wrote were always more problematical than the server.

like image 70
Alister Bulman Avatar answered Oct 28 '22 02:10

Alister Bulman