【发布时间】:2020-12-22 14:38:28
【问题描述】:
我正在尝试使用 Laravel 的通知类在操作时发送系统通知。我在使用同步驱动时收到通知,但是当我切换到 redis 队列连接时,没有通过推送器的有效负载。
SystemNotification.php
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Channels\BroadcastChannel;
use Illuminate\Notifications\Messages\BroadcastMessage;
use Illuminate\Notifications\Notification;
class SystemNotification extends Notification implements ShouldQueue
{
use Queueable;
private $event;
private $eventData;
public function __construct($event, $eventData) {
$this->event = $event;
$this->eventData = $eventData;
}
/**
* Get the delivery channels for this Notification.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable) {
return [BroadcastChannel::class];
}
public function toBroadcast($notifiable) {
return (new BroadcastMessage([
'event' => $this->event,
]));
}
}
.env
BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
QUEUE_CONNECTION=redis
SESSION_DRIVER=file
SESSION_LIFETIME=120
queue.php
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
],
这是我使用同步驱动程序时的有效负载。
我的工作也正在成功处理中。
我将不胜感激任何和所有的帮助。谢谢!
【问题讨论】:
-
你的问题解决了吗?
标签: laravel notifications