Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[Messenger] Add reply functionality #34337
It would be nice to provide developers with possibility to retrieve the result from a handler (with some sort of RPC):
// Get the result from sync transport $envelope = $messageBus->dispatch($message, [new ReplyStamp()]); $replyStamp = $envelope->last(ReplyStamp::class); $result = $replyStamp->getResponse();
// Get the result from amqp transport $envelope = $messageBus->dispatch($message, [new ReplyStamp()]); // do something while messange is being treated $replyStamp = $envelope->last(AmqpReplyStamp::class); $result = $replyStamp->getResponse(); // wait for reponse, blocking call
Let's consider this PR as a discussion to find out:
I will add necssary tests/documentation if community is interested in this implementation.
Thanks for giving your opinion.
The "sync" transport. Is the same as what CQRS would call a QueryBus. That is already implemented, see docs: https://symfony.com/doc/current/messenger/handler_results.html
Your async example is not really RPC, since RPC is blocking if I recall correctly. And, of course, why would we like to write blocking code if we can do unblocking =)