Last active
April 20, 2021 07:12
-
-
Save Nixes/a675ccaef7c83185e2c4798c0de3b965 to your computer and use it in GitHub Desktop.
symfony event handler that runs when a message has been rejected (all retries attempted and failed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MessageOnRejectionSubscriber implements EventSubscriberInterface { | |
public function onMessageFailed(WorkerMessageFailedEvent $event) { | |
// return early if there is still more retrying to do | |
if ($event->willRetry()) { | |
return; | |
} | |
$envelope = $event->getEnvelope(); | |
echo "Message failure caught by ".self::class."\n"; | |
} | |
public static function getSubscribedEvents() { | |
return [ | |
WorkerMessageFailedEvent::class => ['onMessageFailed', -100], | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment