Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Final touches to third tutorial examples.

  • Loading branch information...
commit f10c7468882f6ca234c8211b8537cce14f421b37 1 parent 34aafcd
@majek majek authored
Showing with 11 additions and 9 deletions.
  1. +4 −3 php/emit_log.php
  2. +7 −6 php/receive_logs.php
View
7 php/emit_log.php
@@ -1,11 +1,12 @@
<?php
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
-include_once(__DIR__ . '/config/config.php');
-$connection = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
+$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
-$channel->exchange_declare('logs', 'fanout');
+
+
+$channel->exchange_declare('logs', 'fanout', false, false, false);
$data = implode(' ', array_slice($argv, 1));
if(empty($data)) $data = "info: Hello World!";
View
13 php/receive_logs.php
@@ -1,11 +1,12 @@
<?php
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
-include_once(__DIR__ . '/config/config.php');
-$connection = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
+$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
-$channel->exchange_declare('logs', 'fanout');
+
+
+$channel->exchange_declare('logs', 'fanout', false, false, false);
list($queue_name, ,) = $channel->queue_declare();
@@ -14,11 +15,11 @@
echo ' [*] Waiting for logs. To exit press CTRL+C', "\n";
$callback = function($msg){
- echo $msg->body, "\n";
+ echo ' [x] ', $msg->body, "\n";
};
-$channel->basic_consume($queue_name, 'consumer_tag', false, true, false, false, $callback);
-
+$channel->basic_consume($queue_name, '', false, true, false, false, $callback);
+
while(count($channel->callbacks)) {
$channel->wait();
}
Please sign in to comment.
Something went wrong with that request. Please try again.