8000 [Messenger] ReceiverInterface updated · symfony/symfony-docs@2c2a518 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c2a518

Browse files
Guikingonejaviereguiluz
authored andcommitted
[Messenger] ReceiverInterface updated
1 parent cbd36aa commit 2c2a518

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

components/messenger.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,23 +282,37 @@ do is to write your own CSV receiver::
282282
$this->filePath = $filePath;
283283
}
284284

285-
public function receive(callable $handler): void
285+
public function get(): void
286286
{
287287
$ordersFromCsv = $this->serializer->deserialize(file_get_contents($this->filePath), 'csv');
288288

289289
foreach ($ordersFromCsv as $orderFromCsv) {
290290
$order = new NewOrder($orderFromCsv['id'], $orderFromCsv['account_id'], $orderFromCsv['amount']);
291+
292+
$envelope = new Envelope($order);
291293

292-
$handler(new Envelope($order));
294+
$handler($envelope);
293295
}
296+
297+
return [$envelope];
298+
}
299+
300+
public function ack(Envelope $envelope): void
301+
{
302+
// Add information about the handled message
294303
}
295304

296-
public function stop(): void
305+
public function reject(Envelope $envelope): void
297306
{
298-
// noop
307+
// Reject the message if needed
299308
}
300309
}
301310

311+
.. versionadded:: 4.3
312+
313+
The ``ReceiverInterface`` has been upgraded to act as most libraries
314+
does, be sure to adapt your existing code according to the newly added methods.
315+
302316
Receiver and Sender on the same Bus
303317
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
304318

0 commit comments

Comments
 (0)
0