From 167c735b2edb984afd3bcfea41f1c22a1578f0ac Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Thu, 19 Oct 2023 13:15:25 +0200 Subject: [PATCH] [Messenger] Clarify transport creation example --- components/messenger.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/messenger.rst b/components/messenger.rst index 9d46184bef4..e26e7838107 100644 --- a/components/messenger.rst +++ b/components/messenger.rst @@ -302,17 +302,23 @@ do is to write your own CSV receiver:: { private $serializer; private $filePath; + private $connection; public function __construct(SerializerInterface $serializer, string $filePath) { $this->serializer = $serializer; $this->filePath = $filePath; + + // Available connection bundled with the Messenger component + // can be found in "Symfony\Component\Messenger\Bridge\*\Transport\Connection". + $this->connection = /* create your connection */; } public function get(): iterable { // Receive the envelope according to your transport ($yourEnvelope here), // in most cases, using a connection is the easiest solution. + $yourEnvelope = $this->connection->get(); if (null === $yourEnvelope) { return []; } @@ -338,7 +344,9 @@ do is to write your own CSV receiver:: public function reject(Envelope $envelope): void { // In the case of a custom connection - $this->connection->reject($this->findCustomStamp($envelope)->getId()); + $id = /* get the message id thanks to information or stamps present in the envelope */; + + $this->connection->reject($id); } }