for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace yiicod\jobqueue\commands;
use Illuminate\Queue\WorkerOptions;
use Yii;
use yiicod\cron\commands\DaemonController;
use yiicod\jobqueue\failed\MongoFailedJobProvider;
use yiicod\jobqueue\handlers\ExceptionHandler;
use yiicod\jobqueue\Worker;
/**
* Command to start worker
*
* @author Virchenko Maksim <[email protected]>
*/
class JobQueueCommand extends DaemonController
{
use CommandTrait;
* Get daemon name
* @return string
protected function daemonName(): string
return 'jobqueue-' . $this->queue . '-' . $this->connection;
}
* Run queue worker
protected function worker()
$queueManager = Yii::$app->jobqueue->getQueueManager();
$worker = new Worker($queueManager, new MongoFailedJobProvider(Yii::$app->mongodb, 'yii_jobs_failed'), new ExceptionHandler());
$worker->daemon($this->connection, $this->queue, new WorkerOptions($this->delay, $this->memory, $this->timeout, $this->sleep, $this->maxTries));