Esempio n. 1
0
 /**
  * @param  Exchange $exchange
  * @return $this
  */
 public function addExchange(Exchange $exchange)
 {
     if ($this->hasExchange($exchange->name())) {
         throw new \InvalidArgumentException(sprintf('Exchange "%s" already defined', $exchange->name()));
     }
     $this->exchanges[$exchange->name()] = $exchange;
     return $this;
 }
Esempio n. 2
0
 /**
  * @return void
  */
 public function initialize()
 {
     if ($this->initialized) {
         return;
     }
     $this->initialized = true;
     $this->exchange->initialize();
     $this->queue->initialize();
     $this->channel->queue_bind($this->queue->name(), $this->exchange->name());
 }
 /**
  * @param string $body
  * @param string $routingKey
  * @param array  $properties
  */
 public function publish($body, $routingKey = null, array $properties = array())
 {
     $this->exchange->initialize();
     $message = new AMQPMessage($body, $properties);
     $this->channel->basic_publish($message, $this->exchange->name(), $routingKey);
 }