rabbitmq官网中的php测试helloworld的代码是不是有问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rabbitmq官网中的php测试helloworld的代码是不是有问题相关的知识,希望对你有一定的参考价值。
参考技术A <?phprequire_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare('hello', false, false, false, false);
$msg = new AMQPMessage('Hello World!');
$channel->basic_publish($msg, '', 'hello');
echo " [x] Sent 'Hello World!'\n";
$channel->close();
$connection->close();
?>
receive.php
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPConnection;
$connection = new AMQPConnection('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();
?>
以上是关于rabbitmq官网中的php测试helloworld的代码是不是有问题的主要内容,如果未能解决你的问题,请参考以下文章
无法与 BSC 主网中的合约交互,但在测试网中成功(但仍然是标准传输)