如何在 Laravel 中设置排队通知的最大尝试次数

How to set Max Attempts For Queued Notifications in Laravel

在 laravel 队列系统中处理作业时,我可以为每个作业设置 max tries,并在作业 class 本身中添加一个 public 字段 $tries = n 是否有可能以及如何在实现 shouldQueue 的通知中做同样的事情?

在 Laravel 5.7.14 中是可能的: https://github.com/laravel/framework/pull/26493

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

class TestNotification extends Notification implements ShouldQueue
{
    use Queueable;
    public $tries = 3; // Max tries

    public $timeout = 15; // Timeout seconds
 }