Skip to content

removes names suffixes from queues and exchanges #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions examples/queue_server/consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/queue_server/producer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/topic/anon_consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
4 changes: 2 additions & 2 deletions examples/topic/topic_consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
4 changes: 2 additions & 2 deletions examples/topic/topic_consumer_qos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion examples/topic/topic_producer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
2 changes: 1 addition & 1 deletion lib/Thumper/RpcClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Thumper/RpcServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/RpcClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function addRequest()

return $isContentTypeCorrect && $isCorrelationIdCorrect && $isReplyToCorrect;
}),
$server . '-exchange',
$server,
$routingKey
);

Expand Down
10 changes: 5 additions & 5 deletions tests/RpcServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand All @@ -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())
Expand Down