我目前遇到一个问题,我的电子邮件无法在Laravel 5.8中排队。
我已经跑步:
php artisan queue:table
php artisan migrate
php artisan config:clear
php artisan config:cache
控制器:
$when = now()->addMinutes(2);
$customer->notify((new CustomerOrderItemStatusNotification($orderItem))->delay($when));
.env:
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120
queue.php:
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
]
]
CustomerOrderItemStatusNotification:
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class CustomerOrderItemStatusNotification extends Notification
{
use Queueable;
问题在于它是立即发送此邮件,而不是等待两分钟,也没有在“工作”表中存储任何内容。
答案 0 :(得分:4)
shouldQueue接口的实现类
use Illuminate\Contracts\Queue\ShouldQueue;
class CustomerOrderItemStatusNotification extends Notification implements ShouldQueue
{
use Queueable;