Skip to content

Commit

Permalink
AMQP demo
Browse files Browse the repository at this point in the history
  • Loading branch information
evan2884 committed Dec 15, 2017
1 parent a32f780 commit 1554626
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
6 changes: 0 additions & 6 deletions ZyConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ public function create($bindKey)
}

public function pop()
{
$message = static::$queue->get(AMQP_AUTOACK);
return json_decode($message->getBody(), true);
}

public function popAll()
{
$rs = [];
while ($message = static::$queue->get(AMQP_AUTOACK)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ZyConsumerTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$zyAmqp->setQueueName('queue_demo');
$zyAmqp->create($bindingkey);

while($message = $zyAmqp->popAll()){
while($message = $zyAmqp->pop()){
var_dump($message);
}

Expand Down
13 changes: 4 additions & 9 deletions tests/ZyProducerTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
$zyAmqp->create();

$message = json_encode(array('Hello World3!', 'php3', 'c++3:'));
$routingkey = 'key';
for ($i = 0; $i < 100; $i++) {
if ($routingkey == 'key2') {
$routingkey = 'key';
} else {
$routingkey = 'key2';
}
$zyAmqp->push($message, $routingkey);
}
$routingkey = 'key2';

$zyAmqp->push($message, $routingkey);

0 comments on commit 1554626

Please sign in to comment.