## 1. Using MQTT

Version 2.0 newly builds an MQTT broker based on Netty, and also optimizes the way EMQ is used.

Differences between the old version using EMQ and the new version:

## 2. Topic Management

Topics are managed centrally in this class, marked as publish topic / subscribe topic.<br> <img alt="Topic management page screenshot" src="../../../../business/v2/dev/images/mqtt/mqtt-server01.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />

Simplification of the EMQ client's topic subscription code: subscribe to all subscription properties of the TopicType class.<br> <img alt="Topic management page screenshot" src="../../../../business/v2/dev/images/mqtt/mqtt-server02.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />

Message callback method update:

Received messages are cached by topic into separate Channels in the gateway module for message processing as needed, reducing message peaks for the callback client and improving data processing and forwarding capability and efficiency.<br> <img alt="Topic management page screenshot" src="../../../../business/v2/dev/images/mqtt/mqtt-server03.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />

## 3. MQTT Built on Netty

The cluster is built based on Redis; a more efficient clustering solution will be adopted later.

The startup class is shown below:<br> <img alt="MQTT built on Netty page screenshot" src="../../../../business/v2/dev/images/mqtt/mqtt-server04.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />

## 4. Switching Between EMQ and netty-mqtt

Whether you use EMQ or netty-mqtt, message data is processed the same way. You can choose one of the two, but using both at the same time is not supported.

The configuration that controls which MQTT is used:<br> <img alt="Switching between EMQ and netty-mqtt page screenshot" src="../../../../business/v2/dev/images/mqtt/mqtt-server05.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />
