public function onMessageFailed(WorkerMessageFailedEvent
$event) { if ($event->
willRetry()) { return;
} $throwable =
$event->
getThrowable();
if ($throwable instanceof HandlerFailedException
) { $throwable =
$throwable->
getNestedExceptions()[0
];
} $envelope =
$event->
getEnvelope();
$notification = Notification::
fromThrowable($throwable)->
importance(Notification::IMPORTANCE_HIGH
);
$notification->
subject(sprintf('A "%s" message has just failed: %s.',
$envelope->
getMessage()::
class,
$notification->
getSubject()));
$this->notifier->
send($notification, ...
$this->notifier->
getAdminRecipients());
} public static function getSubscribedEvents(): array
{ return [ WorkerMessageFailedEvent::
class => 'onMessageFailed',
];
}}