Schedule Gearman for a specific date and time

From what I see, Gearman does not support scheduled tasks or task delays. I thought that perhaps the scheduled task can be queued at and then added to the Gearman queue after the expiration of the at time period.

at tasks are permanent because they are written as files to a directory in the server spool directory. Thus, a single bottleneck could potentially be a simple script to add a task to the Gearman queue, because at cannot be distributed between servers. By handing it to Gearman to handle the actual job, I can get the correct logging of work, etc.

This is the best way to approach this, and do you have any alternative ideas?

The reason I chose Gearman over other queue solutions is because it has a PHP extension.

The code I'm writing is used to maintain a queue of emails to be sent. Therefore, I can indicate that I want to send an email to example@example.org at 9.50 on Friday, for example.

+6
linux unix php gearman at-job
source share
3 answers

I decided to take the at route, as outlined in my question. For this purpose, I wrote a small PHP wrapper for the binary binary at and tested it on Ubuntu. If you are interested, it can be found on github: http://github.com/treffynnon/PHP-at-Job-Queue-Wrapper

+2
source share

A fairly hacky solution that will work only with hourly or daily resolution should consist in the name of the task (function) containing the date on which you wanted to send it. Then, so that employees starting in cron come every hour or day to register for these jobs.

For example, if you want to send an email at 9 a.m. on Monday, March 12, 2012, add the task to the queue with the name type email_2012-03-12_09: 00 . Then do the cron job, which launches the job, which is registered for any jobs matching email _ + with the current date and time.

As I said, maybe workable, but pretty hacky!

UPDATE 1: I recently saw that in documents for database resistance, and now a field is saved with the name when_to_run , which is INT and may contain a unix timestamp. This field, it seems, has not yet been specified in the code.

+1
source share

If you use Zend ...

SlmQueue is the abstraction layer of the job queue. This allows you to easily use job queuing systems in your Zend Framework 2. Therefore, it does not force you to specifically use one type of job queue. You can write your code and tasks regardless of the underlying system. This provides greater flexibility and decoupling of systems.

https://github.com/juriansluiman/SlmQueue

0
source share

All Articles