Neither yii queue/run nor ->run() command doesn’t work. The jobs I push are added to \web\runtime\queue. There are also \runtime\queue directory which has just an index.data file.
As far I understand queue/run supposed to run jobs from \runtime\queue while run() is meant to execute \web\runtime\queue data, so I tried to copy data from \web\runtime\queue to \runtime\queue but it still doesn’t work, the index.data is the only file being changed (if I get it right, job.data are supposed to be deleted after executing…).
namespace app\models;
use yii\base\BaseObject;
class WriteJob extends BaseObject implements \yii\queue\JobInterface
{
public $text;
public $file;
public function execute($queue)
{
file_put_contents($this->file, $this->text);
}
}
web.php and console.php:
'bootstrap' => ['log', 'admin', 'queue'],
'aliases' => [
/*.........*/
'@common/mail' => 'mail',
'@runtime/queue' => 'runtime/queue',
],
'components' => [
/*...........*/
'queue' => [
'class' => \yii\queue\file\Queue::class,
'as log' => \yii\queue\LogBehavior::class,
'path' => '@runtime/queue',
],
]
/* specifically web.php */
'debug' => [
'class' => \yii\debug\Module::class,
'panels' => [
'queue' => \yii\queue\debug\Panel::class, //doesn't work either,
], //not sure if it has something to do with main problem
],
Test file path: \web\file.txt - remains empty.
My yii2 project is on OpenServer (in Windows) if it’s somehow matter…
It looks like it’s supposed to work but it doesn’t…
I noticed that runtime\queue\index.data contains just a:0:{} while \web\runtime\index.data has the data of all jobs starting with a:2 (I wonder why not a:0…). So, I copied everything from latter index.data to the former, and all job.data as well. With having it done I got an error at least:
It’s weird, I just had the exact same issue, working on porting a legacy app to yii2 on PHP 5.6.
The problem seems to be related to yii2-queue 2.1.0 which requires “*” for symfony/process, which ends up downloading v4.x which is incompatible with PHP5.
Downgrading to last yii-queue 2.0.x seems to fix the problem.
Beware, the problem may still exist but it’s working case the job is marked as reserved so symfony/process doesn’t kick in yet. Try adding a new job to the queue and run the command again.
If it still fails, set the version of yii2-queue to 2.0.2 in your composer.json & run composer update again.
The only issue left is it works with console command but doesn’t with Yii::$app->queue->run();
So jobs.data from runtime folder are executed, that from web\runtime don’t