java mqtt broker_MQTT client JAVA 和 MQTT broker

Get the latest official version

Apollo 1.7.1

Development Snapshot

Want to help stablize the latest and greatest nightly development build?Warnning: These builds are extremely bleeding edge!

These development builds are automatically tested and deployed by a Jenkins CI server:

Apollo 99-trunk-SNAPSHOT

The development build source code should be directly checked out from oursource code repository

MQTT client JAVA

MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.

mqtt-client provides an ASL 2.0 licensed API to MQTT. It takes care of automatically reconnecting to your MQTT server and restoring your client session if any network failures occur. Applications can use a blocking API style, a futures based API, or a callback/continuations passing API style.

Using from Maven

Add the following to your mavenpom.xmlfile.

org.fusesource.mqtt-client

mqtt-client

1.12

Using from Gradle

Add the following to your gradle file.

compile 'org.fusesource.mqtt-client:mqtt-client:1.12'

Using from any Other Build System

Download theuber jar fileand add it to your build. The uber contains all the stripped down dependencies which the mqtt-client depends on from other projects.

Using on Java 1.4

We also provide anjava 1.4 uber jar filewhich is compatible with Java 1.4 JVMs. This version of the jar does not support SSL connections since the SSLEngine class used to implement SSL on NIO was not introduced until Java 1.5.

Configuring the MQTT Connection

The blocking, future, and callback APIs all share the same connection setup. You create a new instance of theMQTTclass and configure it with connection and socket related options. At a minimum thesetHostmethod be called before attempting to connect.

MQTT mqtt = new MQTT();

mqtt.setHost("localhost", 1883);

// or

mqtt.setHost("tcp://localhost:1883");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值