简体   繁体   中英

Queue notification laravel 5.3 issue

Well im testing this new notification stuff implemented in laravel 5.3 and its great,

i have this notification class which sends a mail to the authenticated user (when he hits a specific route) which is the default code.

notification

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!');
    }

This is the controller functions that instantiates the notification class

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

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

         return redirect('/home');
    }

now while using a ubuntu os , and setting my queue driver as sync which should work fine on localhost QUEUE_DRIVER="sync"

i started a worker php artisan queue:work

But nothing shows on the terminal windows also page still a bit slow (queues are not working) 在此处输入图片说明

i have the default queue.php and i didnt change it, and as i mentioned, im using sync as a driver Any suggested solution?

sync driver doesn't use queues, it allows to run jobs synchronously for running tests for examle.

You need to use one of the driver provided by laravel listed here - Laravel queues , or install some custom like RabbitMQ or something else

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM