1 Star 0 Fork 1

深圳车马慧技术有限公司/RabbitMQDemo

forked from bona_T2/RabbitMQDemo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
receive.php 872 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhuojundu 提交于 2018-03-20 18:01 . 推送rabbitmq的demo
<?php
$config = require "config.php";
require_once $config['vendor']['path'] . '/autoload.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
$connection = new AMQPStreamConnection($config['rabbitmq']['host'], $config['rabbitmq']['port'],
$config['rabbitmq']['login'], $config['rabbitmq']['password'], $config['rabbitmq']['vhost']);
$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,this message is:' ", $msg->body, "'\n";
};
//启动队列消费者(接收消息并处理)
$channel->basic_consume('hello', '', false, true, false, false, $callback);
while (count($channel->callbacks)) {
$channel->wait();
}
$channel->close();
$connection->close();
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/chemaai/RabbitMQDemo.git
git@gitee.com:chemaai/RabbitMQDemo.git
chemaai
RabbitMQDemo
RabbitMQDemo
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385