From eb3c565a0447db71a9ae78a4804c0e72ecdd5819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Thu, 10 May 2018 12:39:04 +0200 Subject: [PATCH] Add exception --- src/Plugin/Router/AsyncSwitchMessageRouter.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Plugin/Router/AsyncSwitchMessageRouter.php b/src/Plugin/Router/AsyncSwitchMessageRouter.php index 290bc82..3238080 100644 --- a/src/Plugin/Router/AsyncSwitchMessageRouter.php +++ b/src/Plugin/Router/AsyncSwitchMessageRouter.php @@ -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; @@ -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;