php - 如何在 PHP 中通过 websockets 代理向 mqtt 订阅/发布消息?
问题描述
我正在寻找一种通过 php 通过 websockets 代理向 RabbitMQ mqtt 发布/订阅消息/频道的方法,但我找不到任何代码或任何好的库。
我找到了https://github.com/bluerhinos/phpMQTT但它看起来是针对 MQTT 的,而不是针对 MQTT-over-websockets 的,而且它看起来已经被废弃了。
为什么这么难 - 我知道我不是第一个寻找它的人?有什么建议么?
谢谢
解决方案
RabbitMQ uses AMQP not MQTT as a messaging protocol. Anyways there are several PHP RabbitMQ libraries out there that wrap the base phpamqplib library. You can of course use the MQTT plugin in which case the Mosquito library should work but I don't really understand why you would want to use MQTT instead of AMQP unless you have embedded devices publishing to your rabbitmq server. In this case you can still use AMQP for consuming messages with PHP.
My favorite PHP AMQP library is Bunny
Here is a benchmark of the different wrapper libraries out there: https://blog.forma-pro.com/php-amqp-clients-benchmark-them-all-8a4e6adb1a6b
amqp-ext is the fastest but it has to be installed into your php installation so I wouldn't recommend it unless you are already running tens of millions of messages a day and need a small performance gain will improve your costs.
推荐阅读
- java - 解析Java中API中的标签时出现Json映射异常
- laravel - 构造优化的 Eloquent 查询
- amazon-web-services - 如何查询有关 Amazon Athena 本身的数据?
- c++ - 将我的 QT 应用程序交叉编译到 raspberry-pi3 时如何修复未知错误
- python - 如何在当前 python 脚本中执行和终止另一个 python 脚本
- selenium - 使用 Selenium (Java) 查找德国电话号码
- linux - shell脚本中字符串中的单引号
- angular - 从同一组件中的 EventEmitter 读取值
- php - 如何在 php:5.4-apache docker 中安装 zip 扩展
- python - 查找路线附近的属性(线串)