2

好吧,我正在测试在 laravel 5.3 中实现的这个新通知的东西,它很棒,

我有这个通知类,它向经过身份验证的用户(当他点击特定路线时)发送邮件,这是默认代码。

通知

namespace App\Notifications;

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

class notifyme extends Notification  implements ShouldQueue
{
    use Queueable;

    public function __construct()
    {
        //
    }
    public function via($notifiable)
    {
        return ['mail'];
    }
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line('The introduction to the notification.')
                    ->action('Notification Action', 'https://laravel.com')
                    ->line('Thank you for using our application!');
    }

这是实例化通知类的控制器函数

public function notifyme()
    {
        $user = Auth::user()

        $user->notify(new notifyme($user));
        //$user->notify((new notifyme($user))->delay(Carbon::now()->addMinutes(10)));

         return redirect('/home');
    }

现在在使用 ubuntu os 时,并将我的队列驱动程序设置为同步,这应该可以在 localhost 上正常工作QUEUE_DRIVER="sync"

我开始了一个工人php artisan queue:work

但是终端窗口上什么也没有显示,页面仍然有点慢(队列不起作用) 在此处输入图像描述

我有默认的 queue.php,我没有更改它,正如我所提到的,我使用同步作为驱动程序 任何建议的解决方案?

4

1 回答 1

7

sync驱动程序不使用队列,它允许同步运行作业以运行测试。

您需要使用此处列出的 laravel 提供的驱动程序之一 - Laravel queues,或者安装一些自定义,如 RabbitMQ 或其他

于 2016-08-20T06:11:09.220 回答