コード例 #1
0
 /** {@inheritDoc} */
 public function createTemporaryQueue(Gate $gate)
 {
     $key = $gate->getRoutingKey();
     $extras = $gate->getExtras();
     $name = sha1(uniqid(mt_rand(), true));
     $connection = $gate->getConnection()->getName();
     // creating temporary gate
     $gate = new Gate($gate->getConnection(), $name, $gate->getExchange(), $name);
     $gate->setRoutingKey($key)->setExtras($extras);
     // creating temporary queuei
     if (!isset($this->providers[$connection])) {
         $this->providers[$connection] = [];
     }
     $channel = $this->getChannel($gate->getConnection());
     $channel->queue_declare($name, false, false, true, false);
     $channel->queue_bind($gate->getQueue(), $gate->getExchange(), $gate->getQueue());
     $this->providers[$connection][$name] = new PhpAmqpLibMessageProvider($this->getChannel($gate->getConnection()), $gate->getQueue());
     return $gate;
 }
コード例 #2
0
ファイル: PeclBroker.php プロジェクト: Wisembly/AMQPBundle
 /** {@inheritDoc} */
 public function getProvider(Gate $gate)
 {
     $name = $gate->getName();
     $connection = $gate->getConnection()->getName();
     if (!isset($this->providers[$connection])) {
         $this->providers[$connection] = [];
     }
     if (!isset($this->providers[$connection][$name])) {
         $queue = new AMQPQueue($this->getChannel($gate->getConnection()));
         $queue->setName($gate->getQueue());
         $this->providers[$connection][$name] = new PeclPackageMessageProvider($queue);
     }
     return $this->providers[$connection][$name];
 }