Skip to content

[Messenger] ReceiverInterface updated #11861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions components/messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,23 +282,37 @@ do is to write your own CSV receiver::
$this->filePath = $filePath;
}

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

foreach ($ordersFromCsv as $orderFromCsv) {
$order = new NewOrder($orderFromCsv['id'], $orderFromCsv['account_id'], $orderFromCsv['amount']);

$envelope = new Envelope($order);

$handler(new Envelope($order));
$handler($envelope);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? I don't see how $handler can be defined here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nice one 🤔

}

return [$envelope];
}

public function ack(Envelope $envelope): void
{
// Add information about the handled message
}

public function stop(): void
public function reject(Envelope $envelope): void
{
// noop
// Reject the message if needed
}
}

.. versionadded:: 4.3

The ``ReceiverInterface`` has been upgraded to act as most libraries
does, be sure to adapt your existing code according to the newly added methods.

Receiver and Sender on the same Bus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down