protected function publish()
 {
     foreach ($this->transactionMessages as $message) {
         $this->locator->getPublisherForMessage($message)->publish($message);
     }
     $this->transactionMessages = [];
 }
 /**
  * {@inheritdoc}
  */
 public function execute($command, callable $next)
 {
     if (!$command instanceof Message) {
         return $next($command);
     }
     return $this->locator->getPublisherForMessage($command)->publish($command);
 }