argayash/yii2-queue

The queue extension for the Yii framework

Installs: 17

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 33

Type:yii2-extension

0.1-alpha 2016-07-07 09:01 UTC

This package is not auto-updated.

Last update: 2024-11-15 19:42:28 UTC


README

Yii 2.0 Queue Extension

Non blocking queue manager for Yii 2.0

#####Install: php composer.phar require argayash/yii2-queue "dev-hakaton-tass"

#####Config:

'components' => [
    'queue' => [
        'class' => \yii\queue\components\QueueComponent::className(),
        'queueName' => 'default-queue',
        'timeout' => 50, // optional
        'workers' => [
            'test' => [
                'class' => \yii\queue\components\WorkerComponent::className(),
                'action' => [
                    'class' => \console\controllers\TestController::className(),
                ]
            ],
            ...
        ],
        'channels' => [
            'default' => [
                'class' => \yii\queue\components\ChannelComponent::className(),
                    'driver' => [
                        'class' => \yii\queue\drivers\MysqlConnection::className(),
                        'connection' => 'db'
                    ]
                ]
            ],
            ...
        ]
    ]
]

Before use apply migrations:

./yii migrate/up --migrationPath=@vendor/argayash/yii2-queue/migrations

###Usage:

Push message to queue:

Yii::$app->queue->getChannel('default')->push(
    new MessageModel([
        'worker' => 'test',
        'method' => 'actionSayHello',
        'arguments' => [
            'say' => 'hello!'
        ]
    ])
);

Run queue worker daemon (console app):

\Yii::$app->queue->startDaemon();