Skip to content

Commit 50617f1

Browse files
committed
minor symfony#19047 [Messenger] Clarify transport creation example (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Messenger] Clarify transport creation example Fix symfony#12680 There are still a few "missing parts", but this is a advanced use case and I think people who needs to create their own receiver will be able to figure out missing lines 🙂 Commits ------- 167c735 [Messenger] Clarify transport creation example
2 parents d7aaf74 + 167c735 commit 50617f1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

components/messenger.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,23 @@ do is to write your own CSV receiver::
302302
{
303303
private $serializer;
304304
private $filePath;
305+
private $connection;
305306

306307
public function __construct(SerializerInterface $serializer, string $filePath)
307308
{
308309
$this->serializer = $serializer;
309310
$this->filePath = $filePath;
311+
312+
// Available connection bundled with the Messenger component
313+
// can be found in "Symfony\Component\Messenger\Bridge\*\Transport\Connection".
314+
$this->connection = /* create your connection */;
310315
}
311316

312317
public function get(): iterable
313318
{
314319
// Receive the envelope according to your transport ($yourEnvelope here),
315320
// in most cases, using a connection is the easiest solution.
321+
$yourEnvelope = $this->connection->get();
316322
if (null === $yourEnvelope) {
317323
return [];
318324
}
@@ -338,7 +344,9 @@ do is to write your own CSV receiver::
338344
public function reject(Envelope $envelope): void
339345
{
340346
// In the case of a custom connection
341-
$this->connection->reject($this->findCustomStamp($envelope)->getId());
347+
$id = /* get the message id thanks to information or stamps present in the envelope */;
348+
349+
$this->connection->reject($id);
342350
}
343351
}
344352

0 commit comments

Comments
 (0)