public function testRabbitMqExtensions() { $spec = new QueueSpecification(array('match_headers_exchange' => 'all', 'ha_policy' => 'all', 'ha_policy_params' => array('user@hostname', 'user2@hostname'), 'expires' => 20, 'message_ttl' => 10, 'dead_letter_exchange' => 'bar', 'dead_letter_routing_key' => 'baz', 'max_length' => 1024)); $this->assertSame('all', $spec->getMatchHeadersExchange()); $this->assertSame('all', $spec->getHaPolicy()); $this->assertEquals(array('user@hostname', 'user2@hostname'), $spec->getHaPolicyParams()); $this->assertSame(20, $spec->getExpires()); $this->assertSame(10, $spec->getMessageTtl()); $this->assertSame('bar', $spec->getDeadLetterExchange()); $this->assertSame('baz', $spec->getDeadLetterRoutingKey()); $this->assertSame(1024, $spec->getMaxLength()); $this->assertEquals(array('x-match' => 'all'), $spec->getBindArguments()); $this->assertEquals(array('x-ha-policy' => "all", 'x-ha-policy-params' => array("user@hostname", "user2@hostname"), 'x-expires' => 20, 'x-message-ttl' => 10, 'x-dead-letter-exchange' => "bar", 'x-dead-letter-routing-key' => "baz", 'x-max-length' => 1024), $spec->getArguments()); // reset all $spec->setMatchHeadersExchange(null); $spec->setHaPolicy(null); $spec->setHaPolicyParams(null); $spec->setExpires(null); $spec->setMessageTtl(null); $spec->setDeadLetterExchange(null); $spec->setDeadLetterRoutingKey(null); $spec->setMaxLength(null); $this->assertEmpty($spec->getArguments()); $this->assertEmpty($spec->getBindArguments()); $this->assertFalse($spec->getMatchHeadersExchange()); $this->assertFalse($spec->getHaPolicy()); $this->assertFalse($spec->getHaPolicyParams()); $this->assertFalse($spec->getExpires()); $this->assertFalse($spec->getMessageTtl()); $this->assertFalse($spec->getDeadLetterExchange()); $this->assertFalse($spec->getDeadLetterRoutingKey()); $this->assertFalse($spec->getMaxLength()); }
/** * @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; }