![]() |
|
sfJobQueuePlugin - 0.1.0Symfony Job Queues |
|
![]() |
15
users
Sign-in
to change your status |
This plugins enables job queues into Symfony. Using a job queue can be useful when asynchronised server-side operations have to be performed (periodically grabbing a RSS feed, automatically sending emails, etc.) or in environments without a cron access. |
| Name | Status | |
|---|---|---|
|
|
lead | gro.tocal <<ta>> reivax |
Copyright (c) 2007 Xavier Lacot
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Version | License | API | Released |
|---|---|---|---|
| 0.3.0beta | MIT license | 0.3.0beta | 04/02/2008 |
| 0.2.0beta | MIT license | 0.2.0beta | 24/10/2007 |
| 0.1.0alpha | MIT license | 0.1.0alpha | 17/09/2007 |
This plugins enables job queues into Symfony. It includes all the common job queues tasks (start, stop, scheduling through job election strategies, etc.), command line tasks, and a graphical interface for managing queues and jobs. Using a job queue can be useful when asynchronised server-side operations have to be performed (periodically grabbing a RSS feed, automatically sending emails, etc.) or in environments without a cron access.
A "job" is a task that has to be done. In this plugin, it is modeled as a call ton a JobHandler, which understands the parameters associated to the job in order to perform a dedicated action. A "job queue" is a group of jobs to be run, eventually several times, associated to a job election strategy. In this plugin, one job queue can only run one job at a time.
go to your project's root
Install the plugin:
./symfony plugin-install http://plugins.symfony-project.com/sfJobQueuePlugin
rebuild the model:
./symfony propel-build-all
clear cache:
./symfony cc
In order to create a job queue, you must first activate the administration module. You can then create a job queue by defining: * its name * its job election strategy (either FIFO or priority-based)
You usually won't need it, but it is also possible to create job queues dynamically, directly from your application's code:
<?php $queue = new sfJobQueue(); $queue->setName('RSS grabbing queue'); $queue->setSchedulerName('fifo'); $queue->save();
By default, the job queue is stopped when created. In order it to get active, you need to start it.
For the moment, running a job queue can only be done through the command line interface:
./symfony sfqueue-start-queue YOUR_APP_NAME QUEUE_NAME
So, for instance :
./symfony sfqueue-start-queue frontend 'RSS grabbing queue'
Adding a job to one job queue is rather simple. You only have to give the type of the job which has to be created, and set its execution parameters.
<?php $queue->addJob('mailing', array('to' => 'xavier@lacot.org', 'topic' => 'Testing the MailingJobQueue :)'));
A job queue can be tweaked using several parameters: * scheduler_name: the scheduler name defines the policy of job election. For instance, with a "fifo" scheduler, the oldest eligible job will be the one who will be processed next. With a "priority" scheduler, the eligible job with the highest priority will be the first out. * polling_delay: time between the end of the execution of one job, and the following job election

At the job level, it is also possible to set some general execution parameters: * max_tries: * retry_delay: retry delay, in seconds (minimal delay between two tries of the same job) * priority: priority : from 0 to 9 (lower to higher) * params: an array of parameters for the job execution
sfJobQueue: * addJob($type = '', $options = null) - Creates a new job in the queue * getNbActiveJobs() - Returns the number of jobs to be done * getNbCompletedJobs() - Returns the number of completed jobs * getStatusText() - Returns the status of the queue, as a text * isRunning() - Indicates whether the queue is running or not * run() - Runs the queue
sfJob: * getStatusText() - Returns the status of the job, as a text * run() - Runs the job
To be done.
Long term runners might want to see: * integration with http://yowl.googlecode.com/svn/trunk/test/test-yowl.html * exposition to Web services
This plugin is licensed under the MIT license and maintained by Xavier Lacot (xavier@lacot.org). External contributions and comments are welcome !
Initial public release.
