一、简介
MQTT(消息队列遥测传输)是ISO 标准(ISO/IEC PRF 20922)下基于发布/订阅范式的消息协议。
此处不再引入官方文字描述,以个人开发认识浅谈一下
本文分为两部分:
二、服务端搭建(Windows)
1.JDK安装及环境变量配置,ok后下一步;
2.前往http://activemq.apache.org/apollo/download.html下载 Apollo 对应window版本,解压到一个不含中文字符的目录下

目录:

3.打开cmd 进入到apollo的bin目录:E:\apache-apollo-1.7.1\bin回车 执行apollo.cmd如下,说明环境搭建正常

创建示例: 还是在E:\apache-apollo-1.7.1\bin 下执行 apollo create mymqtt(自定义你的mqtt实例名称)

在E:\apache-apollo-1.7.1\bin 目录下可以看到新生成的mymqtt文件夹,里面包含 bin 、data、etc、log、tmp文件,这里重点说下etc,里面的apollo.xml是mymqtt的这个实例的配置文件,users.properties 是mymqtt这个实例下登录用户账号密码,默认为账号admin 密码password;
接下来启动实例mymqtt: 在E:\apache-apollo-1.7.1\bin\mymqtt\bin 回车执行apollo-broker.cmd run

在浏览器输入localhost:61680 或61681

默认登录账号密码为admin password 登录后如下:

证明服务端已经建立起来,关于查看当前在线客户端及数据发送概况,在Connectors中(我的Android客户端已连接):

至此MQTT服务端已经搭建完毕,下一步搭建Android客户端。
若你对Android端不太懂,只是想测试搭建的MQTT服务是否可用的话,欢迎下载我刚更新过后传在个人服务器下的测试app,下载链接为:http://www.juster.xyz/download/MQTT.apk 或扫码,仅供测试搭建环境是否OK。

网友评论