Skip to content
a job queue library that use Azure Queue Storage .
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
src
tests
.gitignore
README.md
composer.json
phpunit.xml

README.md

backjob

a job queue library that use Azure Queue Storage .

Installation

Include arakaki-yuji/backjob in your project, by adding it to your composer.json file.

{
    "require": {
        "arakaki-yuji/backjob": "^0.0.5"
    }
}

Usage

Define your own Job

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';
    }
}

Enqueue, dequeue and run a 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'
You can’t perform that action at this time.