a job queue library that use Azure Queue Storage .
Include arakaki-yuji/backjob in your project, by adding it to your composer.json file.
{
"require": {
"arakaki-yuji/backjob": "^0.0.5"
}
}
class CustomJob extends \Backjob\Job
{
/**
* You must define a run method.
* this method is called when dequeued and run
*/
public function run()
{
$msg = $this->params['message'];
return $msg;
}
/**
* this method is optional.
* if you define success method, it is called after run method successed.
*/
public function success()
{
return 'success job';
}
/**
* this method is optional.
* if you define fail method, it is called after run method failed.
*/
public function fail()
{
return 'success job';
}
}
setup a backjob instance.
$backjob = new \Backjob\Backjob::factory($storageAccountName, $queueName, $accessKey);
Enqueue a job
$params = ['message' => 'Hello Backjob'];
$job = CustomeJob::makeJob($params);
$backjob->queue($job);
Dequeue and run a job.
$backjob = new \Backjob\Backjob::factory($storageAccountName, $queueName, $accessKey);
$backjob->run(); // => 'Hello Backjob'