Created
September 23, 2019 17:01
-
-
Save kish2011/931b9dba86c09e1986a1040323b954e8 to your computer and use it in GitHub Desktop.
Receiving data from RabbitMQ queue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__ . '/vendor/autoload.php'; | |
use PhpAmqpLib\Connection\AMQPStreamConnection; | |
$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest'); | |
$channel = $connection->channel(); | |
$channel->queue_declare('hello', false, false, false, false); | |
echo " [*] Waiting for messages. To exit press CTRL+C\n"; | |
$callback = function ($msg) { | |
echo ' [x] Received ', $msg->body, "\n"; | |
}; | |
$channel->basic_consume('hello', '', false, true, false, false, $callback); | |
while (count($channel->callbacks)) { | |
$channel->wait(); | |
} | |
$channel->close(); | |
$connection->close(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment