meioa/php-mqlib
最新稳定版本:v1.0.0
Composer 安装命令:
composer require meioa/php-mqlib
包简介
A simple library for MQ message listening and sending based on php-amqplib
README 文档
README
A simple library for MQ message listening and sending based on php-amqplib
Installation
composer require meioa/php-mqlib
Example
use PhpMqlib\Consumer; use PhpMqlib\Producer; //连接配置信息 $config = [ 'host' => '127.0.0.1', 'port' => 5672, 'login' => 'guest', 'password' => 'guest', 'vhost' => '/', ]; //定义消息处理函数 $callback = function ($msg){ // 方法2: 使用 has 方法检查后获取 if ($msg->has('content_type')) { echo " Content-Type (checked): " . $msg->get('content_type') . "\n"; } var_export($msg->getBody()); echo PHP_EOL; }; //监听 指定队列,处理消息 (new Consumer($config))->run('q11',$callback); $data = ['a'=>123,'b'=>'vv']; //创建 指定交换机 的连接实例 $producer = new Producer($config,'et5'); //发送消息 $producer->send($data,'route'); //发送持久化消息 ,rabbitMq-server 重启后消息不丢失 $producer->setDeliveryMode()->send($data,'route'); //向指定 header 类型交换机 发送 带有headers 参数的 消息 $producer->send($data,'',['h'=>2]);
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-14