Laravel-队列

Laravel-队列

驱动设置

php artisan queue:table

php artisan queue:failed-table

php artisan migrate

创建任务

php artisan make:job [jobName]

委派任务
同步执行

jobName::dispatch()

dispatch(new jobName())

$this->dispatch(new jobName())

异步执行

->onConnection('redis') [选择连接]

->onQueue('default') [选择队列]

->delay(now()->addMinutes(10))) [延迟入队]

监听任务

php artisan queue::work [redis, database] --tries=3 --queue=sms,email,default

任务事件

app/Providers/AppServiceProdiver.php

use IlluminateQueueEventsJobProcessed;
use IlluminateQueueEventsJobProcessing;
use IlluminateSupportFacadesLog;
use IlluminateSupportFacadesQueue;
use IlluminateQueueEventsJobFailed;

原文地址:https://www.cnblogs.com/yanweifeng/p/11168504.html