MQTT和ActiveMQ

本文介绍了如何使用MQTT协议进行Android设备的消息推送,并提供了极光推送服务作为实例。同时,指导了如何通过ActiveMQ搭建消息中间件平台,包括下载与配置Apache.NMS及ActiveMQ的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

MQTT是一个轻量级的消息发布/订阅协议,它是实现基于手机客户端的消息推送服务器的理想解决方案。
消息订阅和推送
地址如下:
https://github.com/tokudu/AndroidPushNotificationsDemo
其服务类文件有许多方法过时例如:
The method onStart(Intent, int) from the type Service is deprecated
use onStartCommand instend of
The field ConnectivityManager.EXTRA_NETWORK_INFO is deprecated
解决方案:
建议使用getActiveNetworkInfo()

NetworkInfo
getActiveNetworkInfo() 获取当前连接可用的网络

http://blog.csdn.net/oyangyujun/article/details/41723865
http://blog.csdn.net/ygc87/article/details/7629749

The method setLatestEventInfo(Context, CharSequence, CharSequence, PendingIntent) from the type Notification is deprecated
解决方案
The Notification.Builder has been added to make it easier to construct Notifications.

在构造notification的时候有很多种写法,但是要注意,用
Notification notification = new Notification();
这种构建方法的时候,一定要加上notification.icon这个设置,不然,程序虽然不会报错,但是会没有效果。

Notification noti = new Notification.Builder(mContext)
.setContentTitle("New mail from " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_mail)
.setLargeIcon(aBitmap)
.build();

2.信息推送方案
极光推送
https://www.jpush.cn/common/products

3.详细文档
http://blog.mcxiaoke.com/mqtt/protocol/MQTT-3.1.1-CN.pdf

  1. Android消息推送(二)--基于MQTT协议实现的推送功能
    http://blog.csdn.net/johnny901114/article/details/8898727

ActiveMQ

一.Activemq 平台搭建与C#示列 http://www.cnblogs.com/woxpp/p/5001373.html
二.ActiveMQ 即时通讯服务 浅析 java示例 http://www.cnblogs.com/hoojo/p/active_mq_jms_apache_activeMQ.html

C#示例
下载
ActiveMQ官方网站下载最新版的Apache.NMS,网址:http://activemq.apache.org/nms/download.html,需要下载Apache.NMS和Apache.NMS.ActiveMQ两个bin包

http://www.apache.org/dyn/closer.lua/activemq/apache-nms/1.7.0/Apache.NMS.ActiveMQ-1.7.1-bin.zip

或者可以

http://www.apache.org/dyn/closer.lua/activemq/apache-nms

一个很好的例子
http://www.ibm.com/developerworks/cn/websphere/library/techarticles/1109_wangb_mqandroid/1109_wangb_mqandroid.html

Mqtt各个平台下用到的包还有例子
https://github.com/mqtt/mqtt.github.io/wiki/libraries

Mqtt调试服务器
http://www.hivemq.com/blog/seven-best-mqtt-client-tools
MQTT.fx

转载于:https://www.cnblogs.com/wyyy/p/4995283.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值