예제 #1
0
 /**
  * @param QueueSpecification $specification
  * @param AMQPChannel $channel
  * @param bool $autoDeclare
  * @return AMQPQueue
  */
 public function create(QueueSpecification $specification, AMQPChannel $channel, $autoDeclare = true)
 {
     $queue = new AMQPQueue($channel);
     if ($specification->getName() != '') {
         $queue->setName($specification->getName());
     }
     $queue->setFlags($specification->getFlags());
     $queue->setArguments($specification->getArguments());
     if ($autoDeclare) {
         $queue->declareQueue();
         $routingKeys = $specification->getRoutingKeys();
         if (empty($routingKeys)) {
             $queue->bind($specification->getExchange(), null, $specification->getBindArguments());
         } else {
             foreach ($routingKeys as $routingKey) {
                 $queue->bind($specification->getExchange(), $routingKey, $specification->getBindArguments());
             }
         }
     }
     return $queue;
 }
 public function testGettersAndSetters()
 {
     $spec = new QueueSpecification(array('name' => 'name', 'connection' => 'testconnection', 'exchange' => 'exchange', 'passive' => true, 'durable' => false, 'exclusive' => true, 'autoDelete' => true, 'arguments' => array('key1' => 'value1', 'key2' => 'value2'), 'routingKeys' => array('r1', 'r2'), 'bindArguments' => array('key3' => 'value3', 'key4' => 'value4')));
     $this->assertSame('name', $spec->getName());
     $this->assertSame('testconnection', $spec->getConnection());
     $this->assertSame('exchange', $spec->getExchange());
     $this->assertTrue($spec->getPassive());
     $this->assertFalse($spec->getDurable());
     $this->assertTrue($spec->getExclusive());
     $this->assertTrue($spec->getAutoDelete());
     $this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $spec->getArguments());
     $this->assertEquals(array('r1', 'r2'), $spec->getRoutingKeys());
     $this->assertEquals(array('key3' => 'value3', 'key4' => 'value4'), $spec->getBindArguments());
 }