/**
  * {@inheritdoc}
  *
  * @return ReadModelInterface|Collection
  */
 public function dispatchNow(MessageInterface $query)
 {
     if (!$query instanceof QueryInterface) {
         throw new InvalidArgumentException(sprintf('Query "%s" should implement \\Borobudur\\Cqrs\\Message\\QueryInterface', get_class($query)));
     }
     $results = parent::dispatchNow($query);
     if (null === $results) {
         return null;
     }
     return $results;
 }
 /**
  * Dispatch command immediately.
  *
  * @param MessageInterface $command
  *
  * @return mixed
  * @throws Exception
  */
 public function dispatchNow(MessageInterface $command)
 {
     $this->beginTransaction();
     try {
         $result = parent::dispatchNow($command);
         $this->commit();
         return $result;
     } catch (Exception $e) {
         $this->rollback();
         throw $e;
     }
 }
 private function getBus()
 {
     $bus = new Bus();
     $bus->register('\\Borobudur\\Bus\\Test\\Message', '\\Borobudur\\Bus\\Test\\MessageHandler');
     return $bus;
 }