8000 Final touches to third tutorial examples. · seanhuang/rabbitmq-tutorials@f10c746 · GitHub
[go: up one dir, main page]

Skip to content

Commit f10c746

Browse files
committed
Final touches to third tutorial examples.
1 parent 34aafcd commit f10c746

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

php/emit_log.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22

33
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
4-
include_once(__DIR__ . '/config/config.php');
54

6-
$connection = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
5+
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
76
$channel = $connection->channel();
8-
$channel->exchange_declare('logs', 'fanout');
7+
8+
9+
$channel->exchange_declare('logs', 'fanout', false, false, false);
910

1011
$data = implode(' ', array_slice($argv, 1));
1112
if(empty($data)) $data = "info: Hello World!";

php/receive_logs.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22

33
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
4-
include_once(__DIR__ . '/config/config.php');
54

6-
$connection = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
5+
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
76
$channel = $connection->channel();
8-
$channel->exchange_declare('logs', 'fanout');
7+
8+
9+
$channel->exchange_declare('logs', 'fanout', false, false, false);
910

1011
list($queue_name, ,) = $channel->queue_declare();
1112

@@ -14,11 +15,11 @@
1415
echo ' [*] Waiting for logs. To exit press CTRL+C', "\n";
1516

1617
$callback = function($msg){
17-
echo $msg->body, "\n";
18+
echo ' [x] ', $msg->body, "\n";
1819
};
1920

20-
$channel->basic_consume($queue_name, 'consumer_tag', false, true, false, false, $callback);
21-
21+
$channel->basic_consume($queue_name, '', false, true, false, false, $callback);
22+
2223
while(count($channel->callbacks)) {
2324
$channel->wait();
2425
}

0 commit comments

Comments
 (0)
0