AckStamp.php 749 B

1234567891011121314151617181920212223242526272829303132333435
  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\Stamp;
  11. use Symfony\Component\Messenger\Envelope;
  12. /**
  13. * Marker stamp for messages that can be ack/nack'ed.
  14. */
  15. final class AckStamp implements NonSendableStampInterface
  16. {
  17. private $ack;
  18. /**
  19. * @param \Closure(Envelope, \Throwable|null) $ack
  20. */
  21. public function __construct(\Closure $ack)
  22. {
  23. $this->ack = $ack;
  24. }
  25. public function ack(Envelope $envelope, \Throwable $e = null): void
  26. {
  27. ($this->ack)($envelope, $e);
  28. }
  29. }