示例#1
0
 /**
  * @inheritDoc
  */
 public function init()
 {
     parent::init();
     try {
         $this->rawChannel = new \AMQPChannel($this->amqp->getRawConnection());
     } catch (\AMQPConnectionException $e) {
         ClientHelper::throwRightException($e);
     }
 }
示例#2
0
 /**
  * @inheritDoc
  */
 public function init()
 {
     parent::init();
     if (!$this->client) {
         throw new InvalidConfigException(\Yii::t('yii', 'AMQP client should be specified'));
     }
     if ($this->name) {
         $this->queueName = $this->queueName ?: $this->name;
         $this->exchangeName = $this->exchangeName ?: $this->name;
     }
     if (!$this->exchangeName) {
         throw new InvalidConfigException(\Yii::t('yii', 'Exchange name should be specified'));
     }
     if (!$this->queueName) {
         throw new InvalidConfigException(\Yii::t('yii', 'Queue name should be specified'));
     }
     if (!$this->client->isConnected()) {
         $this->client->connect();
     }
     $this->channel = $this->client->newChannel();
     $this->exchange = $this->client->newExchange($this->channel, $this->messageType);
     $this->queue = $this->client->newQueue($this->channel, $this->messageType);
     $this->exchange->setName($this->exchangeName);
     $this->exchange->setFlags($this->exchangeFlags);
     $this->exchange->setType($this->exchangeType);
     $this->exchange->declareExchange();
     $this->queue->setName($this->queueName);
     $this->queue->setFlags($this->queueFlags);
     $this->queue->declareQueue();
     $this->queue->bind($this->exchange, $this->routingKey, $this->queueBindArguments);
 }
示例#3
0
 /**
  * @inheritDoc
  */
 protected function setUp()
 {
     parent::setUp();
     $this->client = new Client(['readTimeout' => static::TIMEOUT, 'writeTimeout' => static::TIMEOUT, 'connectTimeout' => static::TIMEOUT]);
     $this->client->connect();
 }