2017 © Pedro Peláez
 

yii2-extension yii2-queue

Yii2 Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk and Gearman

image

joshuakevin/yii2-queue

Yii2 Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk and Gearman

  • Monday, December 18, 2017
  • by talenta
  • Repository
  • 1 Watchers
  • 0 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 79 % Grown

The README.md

, (*1)

Yii2 Queue Extension


An extension for running tasks asyncronously via queues., (*2)

It supported queues based on DB, Redis, RabbitMQ, Beanstalk and Gearman., (*3)

Documentation is at docs/guide/README.md., (*4)

Latest Stable Version Total Downloads Build Status, (*5)

Installation

The preferred way to install this extension is through composer., (*6)

Either run, (*7)

php composer.phar require --prefer-dist yiisoft/yii2-queue

or add, (*8)

"yiisoft/yii2-queue": "~2.0.0"

to the require section of your composer.json file., (*9)

Basic Usage

Each task which is sent to queue should be defined as a separate class. For example, if you need to download and save a file the class may look like the following:, (*10)

class DownloadJob extends BaseObject implements \yii\queue\JobInterface
{
    public $url;
    public $file;

    public function execute($queue)
    {
        file_put_contents($this->file, file_get_contents($this->url));
    }
}

Here's how to send a task into queue:, (*11)

Yii::$app->queue->push(new DownloadJob([
    'url' => 'http://example.com/image.jpg',
    'file' => '/tmp/image.jpg',
]));

Pushes job into queue that run after 5 min:, (*12)

Yii::$app->queue->delay(5 * 60)->push(new DownloadJob([
    'url' => 'http://example.com/image.jpg',
    'file' => '/tmp/image.jpg',
]));

The exact way task is executed depends on the driver used. The most part of drivers can be run using console commands, which the component registers in your application., (*13)

Command that obtains and executes tasks in a loop until queue is empty:, (*14)

yii queue/run

Command launches a daemon which infinitely queries the queue:, (*15)

yii queue/listen

See documentation for more details about driver console commands and their options., (*16)

The component has ability to track status of a job which was pushed into queue., (*17)

// Push a job into queue and get message ID.
$id = Yii::$app->queue->push(new SomeJob());

// The job is waiting for execute.
Yii::$app->queue->isWaiting($id);

// Worker gets the job from queue, and executing it.
Yii::$app->queue->isReserved($id);

// Worker has executed the job.
Yii::$app->queue->isDone($id);

For more details see the guide., (*18)

The Versions

18/12 2017

dev-master

9999999-dev

Yii2 Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk and Gearman

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Roman Zhuravlev

rabbitmq redis gii yii queue beanstalk async db gearman

18/12 2017

1.0.1

1.0.1.0

Yii2 Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk and Gearman

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Roman Zhuravlev

rabbitmq redis gii yii queue beanstalk async db gearman

15/12 2017

1.0.0

1.0.0.0

Yii2 Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk and Gearman

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Roman Zhuravlev

rabbitmq redis gii yii queue beanstalk async db gearman