Skip to content

Commit 9132a32

Browse files
authored
refactor(Messenger): refactoring on get() usage
1 parent c4974ba commit 9132a32

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

components/messenger.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,16 @@ do is to write your own CSV receiver::
284284

285285
public function get(): void
286286
{
287-
$ordersFromCsv = $this->serializer->deserialize(file_get_contents($this->filePath), 'csv');
288-
289-
foreach ($ordersFromCsv as $orderFromCsv) {
290-
$order = new NewOrder($orderFromCsv['id'], $orderFromCsv['account_id'], $orderFromCsv['amount']);
291-
292-
$envelope = new Envelope($order);
293-
294-
$handler($envelope);
287+
// Receive the envelope according to your transport ($yourEnvelope here),
288+
// in most case, using a connection is the easiest solution.
289+
290+
if (null === $yourEnvelope) {
291+
return [];
295292
}
296-
297-
return [$envelope];
293+
294+
// Reject the message if needed
295+
296+
return [$yourEnvelope->with(new CustomStamp($yourEnvelope['id']);
298297
}
299298

300299
public function ack(Envelope $envelope): void

0 commit comments

Comments
 (0)