workerman/rabbitmq 使用这个插件 连接 rabbitmq 从队列获取不到数据

zhou2021

<?php
use Bunny\Channel;
use Bunny\Message;
use Workerman\Worker;
use Workerman\RabbitMQ\Client;

require_once __DIR__ . '/../../vendor/autoload.php';

$worker = new Worker();

$worker->onWorkerStart = function() {
$options = array(
'host' => '120.0.0.1',
'port' => '5672',
'user' => 'admin',
'password' => 'admin',
'debug'=>true,
);
(new Client($options))->connect()->then(function (Client $client) {
return $client->channel();
})->then(function (Channel $channel) {
return $channel->queueDeclare('test', false, false, false, false)->then(function () use ($channel) {
return $channel;
});
})->then(function (Channel $channel) {
echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";
$channel->consume(
function (Message $message, Channel $channel, Client $client) {
echo " [x] Received ", $message->content, "\n";
print_R($message->content);
},
'test',
'',
false,
true
);
});
};
Worker::runAll();

2616 2 0
2个回答

zhou2021

截图 服务器上有上报数据

  • 暂无评论
朕震惊了

看到你代码里连的是 120.0.0.1,是不是错了,应该连127.0.0.1 吧

  • 暂无评论
年代过于久远,无法发表回答
×
🔝