使用可排队通知时:
class MyNotification extends Notification implements ShouldQueue
{
use Queueable;
}
如何处理失败的作业?如果我通过作业类发送电子邮件/通知,我可以使用失败的方法:
public function failed(Exception $exception) {
Log::debug('MyNotification failed');
}
但是,通知中的失败方法不起作用
你应该在这里查看Laravel文档。
例如,在应用服务提供商中,可以添加:
public function boot()
{
Queue::failing(function (JobFailed $event) {
// $event->connectionName
// $event->job
// $event->exception
});
}
处理失败的作业不是通知的责任,而是队列的责任。
Caddy DZ 是正确的,有一个 handle(( 方法来通知: https://github.com/illuminate/notifications/blob/master/SendQueuedNotifications.php#L92
我的问题不是导入异常类,代码应该是:
public function failed(Exception $exception) {
Log::debug('MyNotification failed');
}