【问题标题】:Queue notification laravel 5.3 issue队列通知 laravel 5.3 问题
【发布时间】:2016-08-20 03:51:22
【问题描述】:

我正在测试这个在 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,但我没有更改它,正如我所提到的,我使用同步作为驱动程序 有什么建议的解决方案吗?

【问题讨论】:

    标签: php laravel ubuntu queue laravel-5.3


    【解决方案1】:

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

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

    【讨论】:

    • 我只是想通了,我是来删除答案的,但你有一个正确的答案,所以还是谢谢你(它现在使用数据库)
    • 我知道这可能已经过时了,但我遇到了同样的问题。请问有什么解决办法?我需要创建一个工作来处理发送通知吗?还是我只做$user->notify((new DoctorCheckedIn($value))->delay($time)); ps:$time 是一个碳实例。
    猜你喜欢
    • 1970-01-01
    • 2019-07-23
    • 2017-04-27
    • 2017-06-21
    • 1970-01-01
    • 1970-01-01
    • 2017-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多