Simple multi driver queue system. This is essentially a port of the Laravel queue system.
Still very much a WIP not for use in production!
Although it would be better to use illuminate/queue
directly it has too many dependancies that would replicate silverstripe/framework
functionality at this time. By porting the code we can take advantage of SilverStripes command line framework and dependancy injection whilst still having a feature rich and multi backend queue system.
So our thanks go to Taylor Otwell et al for their excellent work on Laravel.
- SilverStripe 3.1 or newer.
pda/pheanstalk
2.1 or newer for Beanstalkd support
- Synchronous
- SilverStripe Database
- Beanstalkd
- IronMQ
- Amazon SQS
- Redis
Run the following to add this module as a requirement and install it via composer.
$ composer require studiobonito/silverstripe-queue
Copy the 'queue' folder to your the root of your SilverStripe installation.
Configure the queue drivers with the following YAML.
StudioBonito\SilverStripe\Queue\QueueManager:
default: 'db'
db:
driver: 'db'
queue: 'default'
beanstalkd:
driver: 'beanstalkd'
host: 'localhost'
queue: 'default'
ttr: 60
Import the QueueManager
class for ease of use.
use StudioBonito\SilverStripe\Queue\QueueManager;
Use QueueManager::inst()
to get an instance of the QueueManger
class and then call the push()
method passing in the name of a job handler and an array of data.
QueueManager::inst()->push('SendEmail', array('message' => $message));
Job handlers are simple classes that contain a run
method with $job
and $data
parameters.
class SendEmail {
public function run($job, $data)
{
// Code for processing job goes here.
}
}
$ composer install --prefer-dist --dev
$ phpunit
All original work copyright of Taylor Otwell under MIT license. All subsequent work copyright Studio Bonito Ltd. under BSD-2-Clause license.