摘 要
随着移动互联网技术的迅速发展以及智能移动终端的普及,人们的生活变得
更加便捷、丰富,无论是个人还是企业都已受到移动互联网带来的深刻影响,越
来越多的行业也希望利用移动互联网的优势达到降低人力成本、提高工作效率的
目的。在其中的教育行业,师生间存在信息传递不及时、沟通不畅等问题,影响
着教学质量和管理效率,因此提出能及时、可靠、精准地推送多媒体信息的需求,
本项目正是根据某教育学院客户这样的需求提供的一种解决方案。
通过对客户需求的分析以及国内外相关案例和技术的研究,论证需求的可行
性,设计出“基于 MQTT(Message Queuing Telemetry Transport)协议的信息推送
平台系统的设计与实现”的方案,该系统结合 B/S 结构与 C/S 结构的架构模式,
将总体架构细分为服务端、代理端和客户端三个子系统,采用基于 MQTT 协议的
推送技术来实现信息的传播,突出及时、精准送达信息的特点。其中,服务端分
为前端服务器和 Web 服务器,前者使用 Nginx,提供反向代理和负载均衡的功能,
后者采用 Play Framework 框架来开发,服务端的数据管理由 MySQL 数据库提供支
持;代理端基于 C 语言版的 Mosquitto 工程来开发,从而提高开发和运行效率;客
户端采用 Android 系统平台开发,从而支持使用最广泛的智能终端用户群。在开发
工具方面,服务端和客户端工程在 Eclipse 上进行开发,代理端工程开发采用
Sublime Text 2。在功能定义方面,服务端子系统具有内容管理、用户管理、处理
反馈信息等功能;代理端子系统具有发布消息、持久连接用户终端等功能,提供
对 MySQL 数据库操作的支持,改进 MQTT 协议从而实现个性化消息推送机制;
客户端子系统具有消息接收、消息展示、信息反馈、附件下载等功能。
通过对本系统的一系列测试,结果证明实现的功能符合要求,系统的可用性
得到验证,系统总体上满足客户的需求。本项目的开发应用,使得 MQTT 协议的
应用领域得到扩展,也使得本系统成为行业信息推送领域的成功解决方案之一。
关键词:推送技术,MQTT 协议,行业应用,安卓应用,Play 框架
I
ABSTRACT
ABSTRACT
As the rapid development of mobile Internet technology and the popularity of
smart mobile devices, people's life become more convenient and richer. Whether
individuals or companies have been deeply affected by mobile Internet, and more and
more industries want to take advantage of the mobile Internet to reduce labor costs,
improve work efficiency. In the education industry, between teachers and students exist
these problems which not timely transmission of information and poor communication.
These issues are affecting the quality of teaching and management efficiency, so they
put the needs of push timely, reliable, precise multimedia information. This paper provides a solution which based on such needs of an educational institute customer. Through analysis of customer requirements and research related technical at homeand abroad, then demonstrate the feasibility of demand, finally we design the schemewhich build a platform of information push system based on the MQTT(MessageQueuing Telemetry Transport) protocol. The software system’s overall architecturecombined with the browser-server model and the client-server model, and divided intothree parts of server, broker and client.This system’s information dissemination use pushtechnology which based on MQTT protocol, the push mechanism has the advantage ofpush information timely and precisely. The server subsystem is divided into front-endserver and Web server, former running Nginx to provides the capability of reverse proxyand load balancing, and the latter uses Play Framework. Server’s data managementfunction supported by MySQL database. The development of broker subsystem is basedon the Mosquitto project which can provide high efficiency. The development of clientsubsystem uses Android plateform which supports the most common smart devices. Inthe aspect of system’s development tools, both server and client use Eclipse, and thebroker development tool is Sublime Text 2. In the aspect of system’s function moduledefinition, the server subsystem defined these function modules such as contentmanagement, user management, feedback information processing. The brokersubsystem contains these features which message publishing, persistent connection,database operation by MySQL, and personalized message push mechanism by improveMQTT protocol. The client subsystem has these features such as message receiving,message display, information feedback, download attachments.
Through a series of tests of this system, the test report shows the realization of all
II
ABSTRACT
the features to meet the customer’s requirements, and proved the availability of this
system. The meaning of this project successful development widen the MQTT
protocol’s application field, and also makes this system become one of the successful
solutions in the field of industry's information push.
Keywords: push technology, MQTT protocol, industry applications, Android
application, Play Framework
III
目录
目 录
第一章 绪 论 ..................................................................................................................1
1.1 研究背景与意义 ................................................................................................ 1
1.1.1 选题背景与依据 ...................................................................................... 1
1.1.2 研究意义与价值 ...................................................................................... 1
1.2 国内外研究现状 ................................................................................................ 2
1.2.1 国外相关研究现状 .................................................................................. 2
1.2.2 国内相关研究现状 .................................................................................. 3
1.3 论文的主要研究工作 ........................................................................................ 4
1.4 论文的结构安排 ................................................................................................ 5
第二章 相关理论与技术 ................................................................................................6
2.1 推送技术的介绍与选择 .................................................................................... 6
2.1.1 推送简介 .................................................................................................. 6
2.1.2 推送协议的选择 ...................................................................................... 7
2.2 MQTT 协议介绍................................................................................................. 8
2.2.1 MQTT 协议的发展情况........................................................................... 8
2.2.2 MQTT 协议的内容................................................................................... 8
2.2.3 MQTT 协议的实现工程..........................................................................11
2.3 本章小结 ...........................................................................................................11
第三章 系统需求分析 ..................................................................................................12
3.1 系统需求背景 .................................................................................................. 12
3.1.1 客户需求背景 ........................................................................................ 12
3.1.2 系统需求目标 ........................................................................................ 12
3.1.3 系统需求说明 ........................................................................................ 12
3.2 系统功能需求分析 .......................................................................................... 13
3.2.1 用户角色 ................................................................................................ 13
3.2.2 主要功能需求 ........................................................................................ 13
3.3 系统非功能需求分析 ...................................................................................... 21
3.3.1 性能需求 ................................................................................................ 21
3.3.2 约束性需求 ............................................................................................ 21
3.4 本章小结 .......................................................................................................... 22
IV
目录
第四章 系统总体设计 ..................................................................................................23 4.1 系统设计目标与思路 ...................................................................................... 23 4.1.1 系统设计目标 ........................................................................................ 23 4.1.2 系统设计思路 ........................................................................................ 23 4.2 系统架构设计 .................................................................................................. 24 4.3 系统网络设计 .................................................................................................. 25 4.4 系统软件框架设计 .......................................................................................... 26 4.4.1 服务端软件框架 .................................................................................... 26 4.4.2 代理端软件框架 .................................................................................... 27 4.4.3 客户端软件框架 .................................................................................... 28 4.5 系统软件结构设计 .......................................................................................... 29 4.5.1 服务端子系统软件结构设计 ................................................................ 29 4.5.2 代理端子系统软件结构设计 ................................................................ 30 4.5.3 客户端子系统软件结构设计 ................................................................ 30 4.6 系统接口设计 .................................................................................................. 31 4.7 系统功能模块设计 .......................................................................................... 33 4.7.1 服务端子系统功能模块设计 ................................................................ 33 4.7.2 代理端功能模块设计 ............................................................................ 39 4.7.3 客户端功能模块设计 ............................................................................ 41 4.8 系统数据库设计 .............................................................................................. 45 4.8.1 服务端数据库设计 ................................................................................ 45 4.8.2 客户端数据库设计 ................................................................................ 50 4.9 本章小结 .......................................................................................................... 53第五章 系统实现 ..........................................................................................................54 5.1 系统实现的开发环境 ....................................................................................... 54 5.2 系统主要功能的实现 ...................................................................................... 54 5.2.1 服务端数据存储功能的实现 ................................................................ 54 5.2.2 登录功能的实现 .................................................................................... 57 5.2.3 内容管理功能的实现 ............................................................................ 59 5.2.4 用户管理功能的实现 ............................................................................ 61 5.2.5 终端反馈功能的实现 ............................................................................ 63 5.2.6 消息推送功能的实现 ............................................................................ 68 5.2.7 文件上传下载功能的实现 .................................................................... 76
V
目录
1.5 本章小结 .......................................................................................................... 82
第六章 系统测试 ..........................................................................................................83
1.1.3 测试设计 .......................................................................................................... 83
1.2.3 测试用例设计 ........................................................................................ 83
1.2.4 测试环境 ................................................................................................ 84
1.1.4 功能测试 .......................................................................................................... 84
1.1.5 性能测试 .......................................................................................................... 87
1.1.6 测试结论 .......................................................................................................... 88
1.1.7 本章小结 .......................................................................................................... 90
第七章 总结与展望 ......................................................................................................91
2.4 总结 .................................................................................................................. 91
2.5 不足与展望 ...................................................................................................... 92
致 谢 ............................................................................................................................93
参考文献 ........................................................................................................................94