Introduction Message Queue for MQTTDemo project, including the use of various application scenarios, please refer to the documentation comments of the program source code for understanding.

Get multi-language Demo

<div class="codetab"> <input type="radio" name="tabs" id="tab1" class="tab-switch" checked="checked"/> <label for="tab1" class="tab-label">Java</label> <input type="radio" name="tabs" id="tab2" class="tab-switch"/> <label for="tab2" class="tab-label">Python</label> <input type="radio" name="tabs" id="tab3" class="tab-switch"/> <label for="tab3" class="tab-label">PHP</label> <input type="radio" name="tabs" id="tab4" class="tab-switch"/> <label for="tab4" class="tab-label">C</label> <input type="radio" name="tabs" id="tab5" class="tab-switch"/> <label for="tab5" class="tab-label">.NET</label> <input type="radio" name="tabs" id="tab6" class="tab-switch"/> <label for="tab6" class="tab-label">JavaScript</label> <input type="radio" name="tabs" id="tab7" class="tab-switch"/> <label for="tab7" class="tab-label">iOS</label> <div id="tab-content1" class="tab-content"> <table> <thead> <tr> <th> scene </th> <th> Download address </th> </tr> </thead> <tbody> <tr> <td> Example for sending and receiving MQTT messages separately </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-java-demo/src/main/java/com/aliyun/openservices/lmq/example/demo/MQ4IoTSendMessageToMQ4IoTUseSignatureMode.java ">mqtt.demo.java</a></td> </tr> <tr> <td>MQTT signature example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-java-demo/src/main/java/com/aliyun/openservices/lmq/example/demo/MQ4IoTSendMessageToMQ4IoTUseSignatureMode.java">mqtt.signature.mode.demo.java</a></td> </tr> <tr> <td>MQTT Token example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-java-demo/src/main/java/com/aliyun/openservices/lmq/example/demo/MQ4IoTSendMessageToMQ4IoTUseTokenMode.java">mqtt.token.mode.demo.java</a></td> </tr> <tr> <td>MQTT SSL encryption example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-java-demo/src/main/java/com/aliyun/openservices/lmq/example/demo/MQ4IoTSendMessageToMQ4IoTUseSignatureMode.java">mqtt.ssl.demo.java</a></td> </tr> <tr> <td> Example for sending messages through MQTT and subscribing to messages in RocketMQ </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-java-demo/src/main/java/com/aliyun/openservices/lmq/example/demo/MQ4IoTSendMessageToRocketMQ.java ">mqtt.to.rocketmq.demo.java</a></td> </tr> <tr> <td> Example of RocketMQ sending MQTT subscription messages </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-java-demo/src/main/java/com/aliyun/openservices/lmq/example/demo/RocketMQSendMessageToMQ4IoT.java ">rocketmq.to.mqtt.demo.java</a></td> </tr> <tr> <td>MQTT-based sending of ordered messages: RocketMQ-based subscription to ordered messages </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-java-demo/src/main/java/com/aliyun/openservices/lmq/example/demo/MQ4IoTSendOrderMessageToRocketMQ.java">mqtt.ordered.msg.demo.java</a></td> </tr> <tr> <td> Example of asynchronous online /offline notification on an MQTT client </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-java-demo/src/main/java/com/aliyun/openservices/lmq/example/demo/MQTTClientStatusNoticeProcessDemo.java ">mqtt.client.status.notice.demo.java</a></td> </tr> </tbody> </table> </div> <div id="tab-content2" class="tab-content"> <table> <thead> <tr> <th> scene </th> <th> Download address </th> </tr> </thead> <tbody> <tr> <td> Example for sending and receiving MQTT messages separately </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-python-demo/MQTTSendMessage2MQTT.py">mqtt.demo.python</a></td> </tr> <tr> <td>MQTT signature example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-python-demo/MQTTSendMessage2MQTT.py">mqtt.signature.mode.demo.python</a></td> </tr> <tr> <td>MQTT SSL encryption example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-python-demo/MQTTSendMessage2MQTT.py">mqtt.ssl.mode.demo.python</a></td> </tr> </tbody> </table> </div> <div id="tab-content3" class="tab-content"> <table> <thead> <tr> <th> scene </th> <th> Download address </th> </tr> </thead> <tbody> <tr> <td> Example for sending and receiving MQTT messages separately </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-php-demo/MQTTSendMessageToMQTT.php">mqtt.demo.php</a></td> </tr> <tr> <td>MQTT signature example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-php-demo/MQTTConnectUseSignatureMode.php">mqtt.signature.mode.demo.php</a></td> </tr> <tr> <td>MQTT Token example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-php-demo/MQTTConnectUseTokenMode.php">mqtt.token.mode.demo.php</a></td> </tr> <tr> <td>MQTT-based sending of ordered messages: RocketMQ-based subscription to ordered messages </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-php-demo/MQTTSendOrderMessage.php">mqtt.ordered.msg.demo.php</a></td> </tr> </tbody> </table> </div> <div id="tab-content4" class="tab-content"> <table> <thead> <tr> <th> scene </th> <th> Download address </th> </tr> </thead> <tbody> <tr> <td> Example for sending and receiving MQTT messages separately </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-c-demo/src/c/mqttDemo.c">mqtt.demo.c</a></td> </tr> <tr> <td>MQTT signature example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-c-demo/src/c/mqttDemo.c">mqtt.signature.mode.demo.c</a></td> </tr> <tr> <td>MQTT SSL encryption example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-c-demo/src/c/mqttDemo.c">mqtt.ssl.demo.c</a></td> </tr> </tbody> </table> </div> <div id="tab-content5" class="tab-content"> <table> <thead> <tr> <th> scene </th> <th> Download address </th> </tr> </thead> <tbody> <tr> <td> Example for sending and receiving MQTT messages separately </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-DoNet-demo/MQTTDemo.cs">mqtt.demo.net</a></td> </tr> <tr> <td>MQTT signature example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-DoNet-demo/MQTTDemo.cs">mqtt.signature.mode.demo.net</a></td> </tr> <tr> <td>MQTT SSL encryption example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-DoNet-demo/MQTTDemo.cs">mqtt.ssl.mode.demo.net</a></td> </tr> </tbody> </table> </div> <div id="tab-content6" class="tab-content"> <table> <thead> <tr> <th> scene </th> <th> Download address </th> </tr> </thead> <tbody> <tr> <td> Example for sending and receiving MQTT messages separately </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-js-demo/lmqdemo.html">mqtt.demo.javascript</a></td> </tr> <tr> <td>MQTT signature example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-js-demo/lmqdemo.html">mqtt.signature.mode.demo.javascript</a></td> </tr> <tr> <td>MQTT SSL encryption example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-js-demo/lmqdemo.html">mqtt.ssl.demo.javascript</a></td> </tr> <tr> <td>WebSocket message sending and receiving example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/blob/master/lmq-js-demo/lmqdemo.html">mqtt.websocket.demo.javascript</a></td> </tr> </tbody> </table> </div> <div id="tab-content7" class="tab-content"> <table> <thead> <tr> <th> scene </th> <th> Download address </th> </tr> </thead> <tbody> <tr> <td> Example for sending and receiving MQTT messages separately </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/tree/master/lmq-ios-demo/MQTTChatDemo">mqtt.demo.ios</a></td> </tr> <tr> <td>MQTT signature example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/tree/master/lmq-ios-demo/MQTTChatDemo">mqtt.signature.mode.demo.ios</a></td> </tr> <tr> <td>MQTT SSL encryption example </td> <td><a href="https://code.aliyun.com/aliware_mqtt/mqtt-demo/tree/master/lmq-ios-demo/MQTTChatDemo">mqtt.ssl.demo.ios</a></td> </tr> </tbody> </table> </div> </div>

For the complete set of sample code, see mqtt-demo.

Decompress the package after the download is complete. The lmq-demo folder is added. Level-1 folders are categorized based on the development language. Perform debugging as needed.

Demo usage instructions

If used in combination Message Queue for MQTTand other backend message storage products, such as Message Queue for Apache RocketMQto understand the message structure and property mapping. For more information, see Message structure mappings between Message Queue for MQTT and Message Queue for Apache RocketMQ.

Note The demo project integrity may vary depending on specific languages, which will be updated in the future. If some features do not have any Demo, download the corresponding SDKs for the corresponding languages for testing. For more information, see Java examples.

References

The sample code is for reference only. For more information about how to obtain the SDK in the relevant language, see Download the SDK.