diff --git a/README.md b/README.md index 12142ab..c38d274 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Each example has a README.md file that shows how to execute it. All the examples For example, to publish message to RabbitMQ is as simple as this: $producer = new Thumper\Producer($connection); - $producer->setExchangeOptions(array('name' => 'hello-exchange', 'type' => 'direct')); + $producer->setExchangeOptions(array('name' => 'hello', 'type' => 'direct')); $producer->publish($argv[1]); And then to consume them on the other side of the wire: @@ -37,8 +37,8 @@ And then to consume them on the other side of the wire: }; $consumer = new Thumper\Consumer($connection); - $consumer->setExchangeOptions(array('name' => 'hello-exchange', 'type' => 'direct')); - $consumer->setQueueOptions(array('name' => 'hello-queue')); + $consumer->setExchangeOptions(array('name' => 'hello', 'type' => 'direct')); + $consumer->setQueueOptions(array('name' => 'hello')); $consumer->setCallback($myConsumer); //myConsumer could be any valid PHP callback $consumer->consume(5); //5 is the number of messages to consume. diff --git a/examples/queue_server/consumer.php b/examples/queue_server/consumer.php index 763ccb8..29d2a05 100644 --- a/examples/queue_server/consumer.php +++ b/examples/queue_server/consumer.php @@ -34,7 +34,7 @@ }; $consumer = new Thumper\Consumer($registry->getConnection()); -$consumer->setExchangeOptions(array('name' => 'hello-exchange', 'type' => 'direct')); -$consumer->setQueueOptions(array('name' => 'hello-queue')); +$consumer->setExchangeOptions(array('name' => 'hello', 'type' => 'direct')); +$consumer->setQueueOptions(array('name' => 'hello')); $consumer->setCallback($myConsumer); //myConsumer could be any valid PHP callback $consumer->consume(5); //5 is the number of messages to consume diff --git a/examples/queue_server/producer.php b/examples/queue_server/producer.php index a14f16a..c690355 100644 --- a/examples/queue_server/producer.php +++ b/examples/queue_server/producer.php @@ -30,5 +30,5 @@ require __DIR__ . '/../../config/config.php'; $producer = new Thumper\Producer($registry->getConnection()); -$producer->setExchangeOptions(array('name' => 'hello-exchange', 'type' => 'direct')); +$producer->setExchangeOptions(array('name' => 'hello', 'type' => 'direct')); $producer->publish($argv[1]); //The first argument will be the published message diff --git a/examples/topic/anon_consumer.php b/examples/topic/anon_consumer.php index 76678c0..44c126d 100644 --- a/examples/topic/anon_consumer.php +++ b/examples/topic/anon_consumer.php @@ -35,7 +35,7 @@ }; $consumer = new Thumper\AnonConsumer($registry->getConnection()); -$consumer->setExchangeOptions(array('name' => 'logs-exchange', 'type' => 'topic')); +$consumer->setExchangeOptions(array('name' => 'logs', 'type' => 'topic')); $consumer->setRoutingKey($argv[1]); $consumer->setCallback($myConsumer); $consumer->consume(5); diff --git a/examples/topic/topic_consumer.php b/examples/topic/topic_consumer.php index e09b6eb..434937e 100644 --- a/examples/topic/topic_consumer.php +++ b/examples/topic/topic_consumer.php @@ -35,8 +35,8 @@ }; $consumer = new Thumper\Consumer($registry->getConnection()); -$consumer->setExchangeOptions(array('name' => 'logs-exchange', 'type' => 'topic')); -$consumer->setQueueOptions(array('name' => $argv[2] . '-queue')); +$consumer->setExchangeOptions(array('name' => 'logs', 'type' => 'topic')); +$consumer->setQueueOptions(array('name' => $argv[2])); $consumer->setRoutingKey($argv[1]); $consumer->setCallback($myConsumer); $consumer->consume(5); diff --git a/examples/topic/topic_consumer_qos.php b/examples/topic/topic_consumer_qos.php index b5cfca7..106fc99 100644 --- a/examples/topic/topic_consumer_qos.php +++ b/examples/topic/topic_consumer_qos.php @@ -36,8 +36,8 @@ }; $consumer = new Thumper\Consumer($registry->getConnection()); -$consumer->setExchangeOptions(array('name' => 'logs-exchange', 'type' => 'topic')); -$consumer->setQueueOptions(array('name' => $argv[2] . '-queue')); +$consumer->setExchangeOptions(array('name' => 'logs', 'type' => 'topic')); +$consumer->setQueueOptions(array('name' => $argv[2])); $consumer->setRoutingKey($argv[1]); $consumer->setCallback($myConsumer); $consumer->setQos(array('prefetch_size' => null, 'prefetch_count' => 1, 'global' => null)); diff --git a/examples/topic/topic_producer.php b/examples/topic/topic_producer.php index b2a1bd8..e623ec2 100644 --- a/examples/topic/topic_producer.php +++ b/examples/topic/topic_producer.php @@ -30,5 +30,5 @@ require __DIR__ . '/../../config/config.php'; $producer = new Thumper\Producer($registry->getConnection()); -$producer->setExchangeOptions(array('name' => 'logs-exchange', 'type' => 'topic')); +$producer->setExchangeOptions(array('name' => 'logs', 'type' => 'topic')); $producer->publish($argv[1], sprintf('%s.%s', $argv[2], $argv[3])); diff --git a/lib/Thumper/RpcClient.php b/lib/Thumper/RpcClient.php index 88109ff..88cdd7e 100644 --- a/lib/Thumper/RpcClient.php +++ b/lib/Thumper/RpcClient.php @@ -89,7 +89,7 @@ public function addRequest($messageBody, $server, $requestId, $routingKey = '') ); $this->channel - ->basic_publish($message, $server . '-exchange', $routingKey); + ->basic_publish($message, $server, $routingKey); $this->requests++; } diff --git a/lib/Thumper/RpcServer.php b/lib/Thumper/RpcServer.php index 285cb6f..968000a 100644 --- a/lib/Thumper/RpcServer.php +++ b/lib/Thumper/RpcServer.php @@ -47,9 +47,9 @@ class RpcServer extends BaseConsumer public function initServer($name) { $this->setExchangeOptions( - array('name' => $name . '-exchange', 'type' => 'direct') + array('name' => $name, 'type' => 'direct') ); - $this->setQueueOptions(array('name' => $name . '-queue')); + $this->setQueueOptions(array('name' => $name)); } /** diff --git a/tests/RpcClientTest.php b/tests/RpcClientTest.php index 72dfdbf..047d788 100644 --- a/tests/RpcClientTest.php +++ b/tests/RpcClientTest.php @@ -58,7 +58,7 @@ public function addRequest() return $isContentTypeCorrect && $isCorrelationIdCorrect && $isReplyToCorrect; }), - $server . '-exchange', + $server, $routingKey ); diff --git a/tests/RpcServerTest.php b/tests/RpcServerTest.php index 99807fc..5ac4688 100644 --- a/tests/RpcServerTest.php +++ b/tests/RpcServerTest.php @@ -56,11 +56,11 @@ public function initServerHappyPath() ->initServer($name); $exchangeOptions = $this->getReflectionPropertyValue($this->server, 'exchangeOptions'); - $this->assertEquals($name . '-exchange', $exchangeOptions['name']); + $this->assertEquals($name, $exchangeOptions['name']); $this->assertEquals('direct', $exchangeOptions['type']); $queueOptions = $this->getReflectionPropertyValue($this->server, 'queueOptions'); - $this->assertEquals($name . '-queue', $queueOptions['name']); + $this->assertEquals($name, $queueOptions['name']); } /** @@ -76,18 +76,18 @@ public function startHappyPath() $this->mockChannel ->expects($this->once()) ->method('exchange_declare') - ->with($name . '-exchange', 'direct', false, true, false, false, null, null); + ->with($name, 'direct', false, true, false, false, null, null); $this->mockChannel ->expects($this->once()) ->method('queue_declare') - ->with($name . '-queue') + ->with($name) ->willReturn(array($queueName, false, false)); $this->mockChannel ->expects($this->once()) ->method('queue_bind') - ->with($queueName, $name . '-exchange', '', false, null, null); + ->with($queueName, $name, '', false, null, null); $this->mockChannel ->expects($this->once())