Laravel 通知重复错误,通过(数据库,电子邮件)发出多个通知

Bha*_*rti 5 laravel

我有 1500 多个用户,并通过邮件和数据库向他们发送通知,每周使用 cron 和 supervisor 提醒他们一些事情。

我的队列配置:

'database' => [
    'driver' => 'database',
    'table' => 'jobs',
    'queue' => 'default',
    'retry_after' => 90,
],
Run Code Online (Sandbox Code Playgroud)

我的主管配置:

[program:run-cron]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/projectName/artisan queue:work database --sleep=3 --tries=3  --timeout=50 --queue=default,reminder
autostart=true
autorestart=true
user=www-data
numprocs=6
redirect_stderr=true
stdout_logfile=/var/www/html/projectName/storage/logs/supervisor.log
Run Code Online (Sandbox Code Playgroud)

通知代码:

class UserReminderNotification extends Notification implements ShouldQueue
{
    use Queueable;
    public $job,$days,$settings;
    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->queue="reminder";
        $this->user = $data['user'];
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return array('database','mail');
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        $title = 'Reminder Title';

        return (new MailMessage)
            ->subject($title)
            ->view(
                'user.reminder',
                array(
                    'user' => $this->user,
                )
            );
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            'type' => 'user',
            'name' => $this->user->name,
            'messsage' => 'Reminder message';
        ];
    }
}
Run Code Online (Sandbox Code Playgroud)

错误我在失败的工作中得到了什么:

PDOException:SQLSTATE[23000]:违反完整性约束:1062 重复条目 '3fee38fc-8e1f-4212-9e96-12c4af1510c4' 用于键 'PRIMARY'

如您所见,我所缺少的.retry_after 已经大于 --timeout 。

我认为在邮件失败时,当主管在那个时候再次尝试时,它会再次为该数据库通知做条目。奇怪的是,它不是全部来的。