【问题标题】:Laravel 5.5 - Notifications are not being queued?Laravel 5.5 - 通知没有排队?
【发布时间】:2018-04-06 08:56:49
【问题描述】:

我有以下通知类:

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class ConfirmEmailNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct()
    {
       //
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        $user = $notifiable;
        $url = url('/register/confirm/'. $user->confirmation_token);

        return (new MailMessage)
           ->subject('Confirm Email')
           ->markdown('emails.confirm', ['user' => $user, 'url' => $url]);

    }

    public function toArray($notifiable)
    {
        return [
            //
        ];
     }
}

在我的控制器中,我有以下内容:

$when = now()->addSeconds(30);
$user->notify((new ConfirmEmailNotification())->delay($when));

但是没有任何东西被添加到队列表中 - 电子邮件被立即触发?

我将队列配置如下。

在我的环境文件中:

QUEUE_DRIVER=database

在我的 config/queue.php 中,我已将表重命名如下:

'database' => [
        'driver' => 'database',
        'table' => 'queued_jobs',
        'queue' => 'default',
        'retry_after' => 90,
 ],

运行以下命令:

php artisan queue:table

php artisan migrate

php artisan queue:work

我试过php artisan config:clear,但没有区别。

有什么想法吗?

【问题讨论】:

    标签: laravel-5.5 laravel-queue laravel-notification


    【解决方案1】:

    通过重启php artisan serve修复

    【讨论】:

      【解决方案2】:

      就我而言,我忘记更新 .env 文件中的 QUEUE_CONNECTION 属性。

      QUEUE_CONNECTION 更新到 数据库 后,它按预期工作。

      【讨论】:

        猜你喜欢
        • 2021-07-03
        • 1970-01-01
        • 1970-01-01
        • 2021-02-21
        • 2017-08-12
        • 2021-04-05
        • 1970-01-01
        • 2021-02-16
        • 2018-09-08
        相关资源
        最近更新 更多