WorkerMessageFailedEvent.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Messenger\Event;
  11. use Symfony\Component\Messenger\Envelope;
  12. /**
  13. * Dispatched when a message was received from a transport and handling failed.
  14. *
  15. * The event name is the class name.
  16. */
  17. final class WorkerMessageFailedEvent extends AbstractWorkerMessageEvent
  18. {
  19. private $throwable;
  20. private $willRetry = false;
  21. public function __construct(Envelope $envelope, string $receiverName, \Throwable $error)
  22. {
  23. $this->throwable = $error;
  24. parent::__construct($envelope, $receiverName);
  25. }
  26. public function getThrowable(): \Throwable
  27. {
  28. return $this->throwable;
  29. }
  30. public function willRetry(): bool
  31. {
  32. return $this->willRetry;
  33. }
  34. public function setForRetry(): void
  35. {
  36. $this->willRetry = true;
  37. }
  38. }