/** * {@inheritdoc} */ public function dispatch(MessageInterface $command) { if (!$command instanceof CommandInterface) { throw new InvalidArgumentException(sprintf('Command "%s" should implement \\Borobudur\\Cqrs\\Message\\CommandInterface', get_class($command))); } if ($command instanceof JobInterface && $command->isQueued()) { Queue::getInstance()->send(new QueueMessage($command)); return null; } return $this->dispatchNow($command); }
/** * Configure queue. */ private function configureQueue() { $this->queue = Queue::getInstance(); $this->queue->addListener(QueueEvents::RECEIVED, array($this, 'received')); $this->queue->addListener(QueueEvents::STARTED, array($this, 'started')); $this->queue->addListener(QueueEvents::HALTED, array($this, 'halted')); }