Description
I'm studying the implementation of this package to understand how it works. My assumption was that if I send a multiple queries to the QueryBus, each implementing AsyncMessage, then they would be resolved concurrently (assuming there are multiple consumers to process them). Is this how it is supposed to work?
After studying the EnqueueMessageProducer I don't think this is the case though. When resolving a query the producer calls $reply = $this->producer->sendCommand($this->commandName, $enqueueMessage, (bool) $deferred);
but then immediately calls $reply->receive($this->replyTimeout)
which is blocking (according to it's docblock).
According to enqueue documentation you should do this:
$promise = $producer->sendCommand(Commands::RUN_COMMAND, new RunCommand('debug:container'), true);
// do other stuff.
if ($replyMessage = $promise->receive(5000)) {
So when running multiple queries concurrently I'm guessing it should go something like this:
$promise1 = $producer->sendCommand(..., true);
$promise2 = $producer->sendCommand(..., true);
$promise3 = $producer->sendCommand(..., true);
$promise1->receive(5000);
$promise2->receive(5000);
$promise3->receive(5000);
But since sendCommand
and receive
are not separated in the current code, I think multiple queries (as in multiple QueryBus::dispatch()
calls) will be resolves sequentially. Is that right? If so, is that intended? Why? Is there any way to resolve the queries concurrently?