/**
  * {@inheritdoc}
  */
 public function getExchangeForMessage(Message $message)
 {
     $class = get_class($message);
     if (!isset($this->exchanges[$class])) {
         throw MissingExchangeException::forMessage($message);
     }
     return $this->exchanges[$class];
 }
 /**
  * {@inheritdoc}
  */
 public function publish(Message $message)
 {
     $exchange = $this->getExchange($message);
     if (!$exchange instanceof \AMQPExchange) {
         throw MissingExchangeException::forMessage($message);
     }
     try {
         return $this->publishToExchange($message, $exchange);
     } catch (\AMQPException $e) {
         throw FailedToPublishException::fromException($message, $e);
     }
 }