java moquette,moquette

What is Moquette?

moquette.svg?branch=master

Moquette aims to be a MQTT compliant broker. The broker supports QoS 0, QoS 1 and QoS 2.

Its designed to be evented, uses Netty for the protocol encoding and decoding part, the protocol logic

is essentially a single threaded and it's isolated from front connectors part by LMAX disruptor's ring buffer.

Who use it?

[Freedomotic] (http://www.freedomotic.com/) Is an home automation framework, uses Moquette embedded to interface with MQTT world.

Part of moquette are also used into the [Vertx MQTT module] (https://github.com/giovibal/vertx-mqtt-broker-mod), into MQTT spy

and into [WSO2 Messge broker] (http://techexplosives-pamod.blogspot.it/2014/05/mqtt-transport-architecture-wso2-mb-3x.html).

1 minute set up

Start play with it, download the self distribution tar from BinTray ,

the un untar and start the broker listening on 1883 port and enjoy!

tar zxf distribution-0.6-bundle-tar.tar.gz

cd bin

./moquette.sh

Running inside OSGi container

Starting from version 0.6 Moquette is OSGi compliant, to see it in action:

mvn clean install;

cd bundle;

mvn install pax:provision

Embedding in other projects

To embed Moquette in another maven project is sufficient to include a repository and declare the dependency:

bintray

http://dl.bintray.com/andsel/maven/

true

false

Include dependency in your project:

org.dna.mqtt

moquette-broker

0.6

Build from sources

After a git clone of the repository, cd into the cloned sources and: mvn clean package.

In distribution/target directory will be produced the selfcontained tar for the broker with all dependencies and a running script.

SSL configuration

Here are some simple steps to do to configure Moquette to serve over SSL

**Details **

Moquette uses JavaKeyStore? and certificates to handle SSL. In order to expose it over SSL you have create a keystore for

the broker (select the password), exporting a certificate and define 4 variables into moquette.conf.

Create a keystore

In a directory generate the keystore using the JRE's keytool:

keytool -keystore serverkeystore.jks -alias testserver -genkey -keyalg RSA

To make it work you have to answer at the first question, say moquette.dna.org and as password we could use passw0rdsrv

for both (keystore and keymanger)

Export a certificate

Then you need export a certificate:

keytool -export -alias testserver -keystore serverkeystore.jks -file testserver.crt

Imporing on the client side

Supposing you have already created the keystore for the client side, (name it clientkeystore for example), we could import the certificate with:

keytool -keystore clientkeystore.jks -import -alias testserver -file testserver.crt -trustcacerts

It's done! We just need use the Paho client to connect to the server, check ServerIntegrationSSLTest.java integration test to see how.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Moquette是一个基于JavaMQTT消息代理服务器,它是Mosquitto的一个替代选择。与Mosquitto类似,Moquette提供了一个开源的、可扩展的MQTT代理服务器,用于实现MQTT协议的消息传递。 使用Moquette作为MQTT代理服务器,你可以按照以下步骤进行: 1. 下载和配置Moquette:首先,你需要从Moquette的官方网站或GitHub仓库下载Moquette的发布版本。解压缩下载的文件,并进行必要的配置,例如指定端口号、认证机制和其他参数。 2. 启动Moquette代理服务器:在配置完成后,你可以通过运行Moquette的启动脚本或命令行命令来启动Moquette代理服务器。这将启动一个监听指定端口的MQTT代理服务器。 3. 编写MQTT客户端代码:使用任何支持MQTT协议的客户端库,如Paho MQTT库,编写你的MQTT客户端代码。通过指定Moquette代理服务器的IP地址和端口号,你的客户端将能够连接到Moquette代理服务器并进行MQTT通信。 4. 实现消息发布和订阅:在你的MQTT客户端代码中,你可以实现消息的发布和订阅操作。你可以定义主题、发布消息到指定主题、订阅特定主题以接收消息等。 5. 运行MQTT客户端:构建并运行你的MQTT客户端应用程序,它将连接到Moquette代理服务器,并执行MQTT通信操作。 请注意,Moquette作为一个基于JavaMQTT代理服务器,可以在任何支持Java运行环境的平台上运行,包括Android。因此,你可以在Android应用程序中使用Moquette作为MQTT代理服务器。 总结起来,使用Moquette作为MQTT代理服务器的步骤包括下载和配置Moquette、启动代理服务器、编写MQTT客户端代码,实现消息发布和订阅,并最终运行你的MQTT客户端应用程序。这样,你就能够在Android或其他平台上实现MQTT通信。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值