讨论数量:
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ProcessPodcast implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* 创建一个新的任务实例。
*
* @return void
*/
public function __construct()
{
$this->onQueue('processing');
}
}
函数原型
/**
* Set the desired queue for the job.
*
* @param string|null $queue
* @return $this
*/
public function onQueue($queue)
{
$this->queue = $queue;
return $this;
}
listener 拿屬性不是實例化監聽類去拿的 是反射去拿的 所以在構造函數裡面賦值是不生效的 只能直接給屬性賦值
或者通過viaQueue方法去設置