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:

  1. enableLmq = true
  2. 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.

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

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

  1. username=xxx // Authorization verification account configuration
  2. secretKey=xxx // Authorization verification account configuration
  3. NAMESRV_ADDR=xxx //namesrv access point
  4. eventNotifyRetryTopic=xx //notify retry topic, created in advance
  5. 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.

  1. sh meta.sh start
  2. sh mqtt.sh start

Example Description

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

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