代码之家  ›  专栏  ›  技术社区  ›  Arash Moosapour

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

  •  4
  • Arash Moosapour  · 技术社区  · 7 年前

    在laravel队列系统中,当处理作业时,我可以设置 max tries 对于在job类本身中添加公共字段$trys=n的每个作业 在实现shouldQueue的通知中是否可能以及如何做同样的事情?

    1 回复  |  直到 7 年前
        1
  •  5
  •   Michail Strokin    6 年前

    在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
     }