物联网已经深深融入我们生活当中,智能家居,智能家电,智慧医疗,智慧城市等通过物联网技术实现了万物互联,大大方便人们生活。当前,我们经历第一代物联网:联网模块+APP;正迈向第二代智能物联网:不仅仅是联网,更需要获取设备运行状态,感知运行环境,可控制管理,智能交互等,而这些,需要核心技术IOT支持,hiveMQ是IOT技术关键消息中间件。hiveMQ 企业版和专业版有强大功能,除了智能设备消息处理,还可提供下面增强功能。
1、HiveMQ Enterprise Extension for Kafka
2、HiveMQ Enterprise Extension for Amazon Kinesis
3、HiveMQ Enterprise Extension for Google Cloud Pub/Sub
hiveMQ通过MQTT,Http,over Websoket可高效将智能设备链接,下面演示怎么使用hiveMQ对消息操作。
1、安装 hiveMQ CE
docker run --name hivemq-ce -d -p 1883:1883 hivemq/hivemq-ce
2、MacOS 安装mqtt-client
brew install hivemq/mqtt-cli/mqtt-cli
3、Centos 安装mqtt-client
sudo yum install -y https://github.com/hivemq/mqtt-cli/releases/download/v4.15.0/mqtt-cli-4.15.0.rpm
4、测试验证
mqtt test -h 14.*.*.* -p 1883
MQTT 3: OK
- Maximum topic length: 65535 bytes
- QoS 0: Received 10/10 publishes in 109.54ms
- QoS 1: Received 10/10 publishes in 209.29ms
- QoS 2: Received 10/10 publishes in 304.70ms
- Retain: OK
- Wildcard subscriptions: OK
- Shared subscriptions: OK
- Payload size: >= 100000 bytes
- Maximum client id length: 65535 bytes
- Unsupported Ascii Chars: ALL SUPPORTED
MQTT 5: OK
- Connect restrictions:
> Retain: OK
> Wildcard subscriptions: OK
> Shared subscriptions: OK
> Subscription identifiers: OK
> Maximum QoS: 2
> Receive maximum: 10
> Maximum packet size: 268435460 bytes
> Topic alias maximum: 5
> Session expiry interval: Client-based
> Server keep alive: Client-based
mqtt test -h 14.*.*.* -p 1883 -a -V 5
MQTT 5: OK
- Connect restrictions:
> Retain: OK
> Wildcard subscriptions: OK
> Shared subscriptions: OK
> Subscription identifiers: OK
> Maximum QoS: 2
> Receive maximum: 10
> Maximum packet size: 268435460 bytes
> Topic alias maximum: 5
> Session expiry interval: Client-based
> Server keep alive: Client-based - Maximum topic length: 65535 bytes
- QoS 0: Received 10/10 publishes in 88.96ms
- QoS 1: Received 10/10 publishes in 92.26ms
- QoS 2: Received 10/10 publishes in 18.41ms
- Retain: OK
- Wildcard subscriptions: OK
- Shared subscriptions: OK
- Payload size: >= 100000 bytes
- Maximum client id length: 65535 bytes
- Unsupported Ascii Chars: ALL SUPPORTED
5、发布/订阅消息
1)启动sub订阅topic test消息
mqtt sub -t test -h 14.*.*.* -p 1883
Hello
Hello,iot,wellcome
2)启动pub向topic test发布消息
mqtt pub -t test -m "Hello" -h 14.*.*.*5 -p 1883
mqtt pub -t test -m "Hello,iot,wellcome" -h 14.*.*.* -p 1883
3、订阅多个topic消息
mqtt sub -t topic1 -t topic2 -q 2 -h 14.*.*.* -p 1883
4、订阅topic消息,存入到指定文件
mqtt sub -t topic -h 14.*.*.* -p 1883 -of publishes.log
cat publishes.log
Hello
iot message