If the MessageProducerPlugin is attached to a message bus it routes all messages to the Prooph\ServiceBus\Async\MessageProducer it is initialized with.
Наследование: implements Prooph\Common\Event\ActionEventListenerAggregate, use trait Prooph\Common\Event\DetachAggregateHandlers
 /**
  * @test
  */
 public function it_adds_message_producer_as_event_listener_on_dispatch_initialize()
 {
     $messageProducer = $this->prophesize(MessageProducer::class);
     $eventBus = $this->prophesize(EventBus::class);
     $actionEvent = $this->prophesize(ActionEvent::class);
     $actionEventEmitter = $this->prophesize(ActionEventEmitter::class);
     $listenerHandler = $this->prophesize(ListenerHandler::class);
     $messageProducerPlugin = new MessageProducerPlugin($messageProducer->reveal());
     $actionEventEmitter->attachListener(MessageBus::EVENT_INITIALIZE, [$messageProducerPlugin, 'onDispatchInitialize'])->willReturn($listenerHandler->reveal())->shouldBeCalled();
     $messageProducerPlugin->attach($actionEventEmitter->reveal());
     $actionEvent->getTarget()->willReturn($eventBus->reveal());
     $eventListeners = ['i_am_an_event_listener'];
     $actionEvent->getParam(EventBus::EVENT_PARAM_EVENT_LISTENERS, [])->willReturn($eventListeners);
     //Message Producer should be added to list of event listeners
     $eventListeners[] = $messageProducer->reveal();
     $actionEvent->setParam(EventBus::EVENT_PARAM_EVENT_LISTENERS, $eventListeners)->shouldBeCalled();
     $messageProducerPlugin->onDispatchInitialize($actionEvent->reveal());
 }