Skip to main content
Version: 5.0

RocketMQ MQTT QuickStart

System Requirements

  • 64-bit operating system, Linux/Unix/macOS recommended
  • 64-bit JDK 1.8+

Deployment Instructions

Since the RocketMQ-MQTT project relies on the underlying multi-queue distribution of RocketMQ, RocketMQ supports this feature from version 4.9.3, so you need to confirm that the version of RocketMQ is upgraded to 4.9.3 or later, and ensure that the following configuration items are enabled:

enableLmq = true 
enableMultiDispatch = true

For the deployment of RocketMQ-MQTT, refer to the project description, download the project release version or build it directly from the source code.

git clone https://github.com/apache/rocketmq-mqtt
cd rocketmq-mqtt
mvn -Prelease-all -DskipTests clean install -U
cd distribution/target/

After the source code is built, edit conf/service.conf to complete the MQTT related configuration, as follows

username=xxx    // Authorization verification account configuration
secretKey=xxx // Authorization verification account configuration
NAMESRV_ADDR=xxx //namesrv access point
eventNotifyRetryTopic=xx //notify retry topic, created in advance
clientRetryTopic=xx //Client message retry topic, created in advance

Other launch configuration and pre-step reference projects README.md

Finally start the meta service and then the mqtt broker. Go to the distribution/target/bin directory and start the process.

sh meta.sh start
sh mqtt.sh start

Example Description

The basic code is provided in the project engineering code, see the code example

MqttConsumer.java  // MQTT client initiates subscription message
MqttProducer.java // MQTT client starts publishing messages
RocketMQConsumer.java // RocketMQ client starts subscription message
RocketMQProducer.java // RocketMQ client starts publishing messages