Skip to content

Commit

Permalink
Add exception
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag authored May 10, 2018
1 parent 046842b commit eb3c565
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Plugin/Router/AsyncSwitchMessageRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Prooph\Common\Event\DetachAggregateHandlers;
use Prooph\ServiceBus\Async\AsyncMessage;
use Prooph\ServiceBus\Async\MessageProducer;
use Prooph\ServiceBus\Exception\RuntimeException;
use Prooph\ServiceBus\CommandBus;
use Prooph\ServiceBus\EventBus;
use Prooph\ServiceBus\MessageBus;
Expand Down Expand Up @@ -71,9 +72,11 @@ public function onRouteMessage(ActionEvent $actionEvent): void

if ($actionEvent->getTarget() instanceof CommandBus || $actionEvent->getTarget() instanceof QueryBus) {
$actionEvent->setParam(MessageBus::EVENT_PARAM_MESSAGE_HANDLER, $this->asyncMessageProducer);
} else {
} elseif ($actionEvent->getTarget() instanceof EventBus) {
//Target is an event bus so we set message producer as the only listener of the message
$actionEvent->setParam(EventBus::EVENT_PARAM_EVENT_LISTENERS, [$this->asyncMessageProducer]);
} else {
throw new RuntimeException("Unexpected bus implementation. This plugin is only compatible with standard CommandBus, QueryBus and EventBus implementations.");
}

return;
Expand Down

0 comments on commit eb3c565

Please sign in to comment.