php - YII2extend yii2-queue -
the official example::
$id=yii::$app->queue->push(new downloadjob([ 'url' => 'www.baidu.com', 'file' => '111-txt', ])); // 将作业推送到队列并获得其id // 这个作业等待执行。 $res_waiting=yii::$app->queue->iswaiting($id); // worker 从队列获取作业,并执行它。 $res_reserved=yii::$app->queue->isreserved($id); // worker 作业执行完成。 $res_done=yii::$app->queue->isdone($id); file_put_contents('queue.json',json_encode( [ 'id'=>$id, 'waiting'=>$res_waiting, 'reserved'=>$res_reserved, 'done'=>$res_done ] ),file_append);
downloadjob.php
<?php namespace backend\controllers; use yii\base\object; class downloadjob extends object implements \yii\queue\job { public $url; public $file; public function execute($queue) { file_put_contents('test.txt','111111111'); } }
queue.json {"id":"1","waiting":true,"reserved":false,"done":false}
isreserved()andisdone()these 2 methods fail.why that,who can give example. email:qiangzaiying123@gmail.com. thank platform. thank you.
Comments
Post a Comment