/**
  * @param $queueName
  * @param $message
  */
 public function consume($queueName, $message)
 {
     if ($queueName === $this->eventQueueName) {
         $this->eventConsumer->consume($message);
     } elseif ($queueName === $this->commandQueueName) {
         $this->commandConsumer->consume($message);
     }
     $this->log('debug', 'Consumed ' . $queueName . '.');
 }
 public function execute(AMQPMessage $msg)
 {
     try {
         $this->consumer->consume($msg->body);
         $this->eventDispatcher->dispatch(Events::MESSAGE_CONSUMED, new MessageConsumed($msg));
         return true;
     } catch (Exception $exception) {
         $this->eventDispatcher->dispatch(Events::MESSAGE_CONSUMPTION_FAILED, new MessageConsumptionFailed($msg, $exception));
         return false;
     }
 }
 /**
  * Consume a message and make sure we log errors.
  *
  * @param string                     $queueName
  * @param mixed                      $message
  * @param SerializedEnvelopeConsumer $consumer
  *
  * @throws \Exception
  */
 private function doConsume($queueName, $message, SerializedEnvelopeConsumer $consumer = null)
 {
     if ($consumer === null) {
         $exceptionMessage = sprintf('No consumer was found for queue named "%s"', $queueName);
         $this->log('alert', $exceptionMessage, ['message' => $message]);
         throw new \RuntimeException($exceptionMessage);
     }
     try {
         $consumer->consume($message);
     } catch (\Exception $e) {
         $this->log('error', sprintf('Tried to handle message from queue %s but failed', $queueName), ['exception' => $e, 'message' => $message]);
         throw $e;
     }
 }