ReceiverInterface.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\Transport\Receiver;
  11. use Symfony\Component\Messenger\Envelope;
  12. use Symfony\Component\Messenger\Exception\TransportException;
  13. /**
  14. * @author Samuel Roze <samuel.roze@gmail.com>
  15. * @author Ryan Weaver <ryan@symfonycasts.com>
  16. */
  17. interface ReceiverInterface
  18. {
  19. /**
  20. * Receives some messages.
  21. *
  22. * While this method could return an unlimited number of messages,
  23. * the intention is that it returns only one, or a "small number"
  24. * of messages each time. This gives the user more flexibility:
  25. * they can finish processing the one (or "small number") of messages
  26. * from this receiver and move on to check other receivers for messages.
  27. * If this method returns too many messages, it could cause a
  28. * blocking effect where handling the messages received from one
  29. * call to get() takes a long time, blocking other receivers from
  30. * being called.
  31. *
  32. * If applicable, the Envelope should contain a TransportMessageIdStamp.
  33. *
  34. * If a received message cannot be decoded, the message should not
  35. * be retried again (e.g. if there's a queue, it should be removed)
  36. * and a MessageDecodingFailedException should be thrown.
  37. *
  38. * @throws TransportException If there is an issue communicating with the transport
  39. *
  40. * @return Envelope[]
  41. */
  42. public function get(): iterable;
  43. /**
  44. * Acknowledges that the passed message was handled.
  45. *
  46. * @throws TransportException If there is an issue communicating with the transport
  47. */
  48. public function ack(Envelope $envelope): void;
  49. /**
  50. * Called when handling the message failed and it should not be retried.
  51. *
  52. * @throws TransportException If there is an issue communicating with the transport
  53. */
  54. public function reject(Envelope $envelope): void;
  55. }