调试命令
php artisan queue:work --queue='队列名'
php artisan queue:listen --queue='队列名'
1、调用
$job = (new ExampleJob('@qq.com'))->onQueue('order');
$this->dispatch($job);
2、处理
<?php
namespace App\Jobs;
class ExampleJob extends Job
{
public $email;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($email)
{
$this->email = $email;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$this->fail('342342');
}
/**
* 处理失败任务
*
* @return void
*/
public function failed()
{
echo $this->email;
// Called when the job is failing...
}
}
网友评论