All Products
Search
Document Center

ApsaraMQ for MQTT:Demo projects

Last Updated:Feb 03, 2026

This topic introduces the demo projects for ApsaraMQ for MQTT. These projects provide guidance for various scenarios. For more information, see the comments in the source code.

Get multi-language demos

For the complete sample code, see mqtt-demo.

After you download and decompress the package, a folder named mqtt-demo-main is created on your local machine. The top-level folders are categorized by programming language. You can debug the code as needed.

Java

Scenario

Download link

Standalone MQTT message sending and receiving example

mqtt.demo.java

MQTT token example

mqtt.token.mode.demo.java

MQTT SSL encryption example

mqtt.ssl.demo.java

Example of sending messages from MQTT and subscribing to them in ApsaraMQ for RocketMQ

mqtt.to.rocketmq.demo.java

Example of sending messages from ApsaraMQ for RocketMQ and subscribing to them in MQTT

rocketmq.to.mqtt.demo.java

Example of sending ordered messages from MQTT and subscribing to them as ordered messages in ApsaraMQ for RocketMQ

mqtt.ordered.msg.demo.java

Example of asynchronous notifications for MQTT client online and offline status

mqtt.client.status.notice.demo.java

MQTT SSL mutual authentication example

mqtt.bissl.demo.java

Python

Scenario

Download link

Standalone MQTT message sending and receiving example

mqtt.demo.python

MQTT SSL encryption example

mqtt.ssl.mode.demo.python

PHP

Scenario

Download link

Standalone MQTT message sending and receiving example

mqtt.demo.php

MQTT token example

mqtt.token.mode.demo.php

Example of sending ordered messages from MQTT and subscribing to them as ordered messages in ApsaraMQ for RocketMQ

mqtt.ordered.msg.demo.php

C

Scenario

Download link

Standalone MQTT message sending and receiving example

mqtt.demo.c

MQTT SSL encryption example

mqtt.ssl.demo.c

Note

For more C dependency libraries, see eclipse/paho.mqtt.c.

.NET

Scenario

Download link

Standalone MQTT message sending and receiving example

mqtt.demo.net

MQTT SSL encryption example

mqtt.ssl.mode.demo.net

JavaScript

Scenario

Download link

Standalone MQTT message sending and receiving example

mqtt.demo.javascript

MQTT SSL encryption example

mqtt.ssl.demo.javascript

WebSocket message sending and receiving example

mqtt.websocket.demo.javascript

iOS

Scenario

Download link

Standalone MQTT message sending and receiving example

mqtt.demo.ios

MQTT SSL encryption example

mqtt.ssl.demo.ios

Notes on using the demos

If you use ApsaraMQ for MQTT with other backend log brokers, such as ApsaraMQ for RocketMQ, you must understand the message structure and property mapping. For more information, see Message structure mapping between MQTT and ApsaraMQ for RocketMQ.

Note

The demo programs for different programming languages may vary in completeness and are periodically updated. If a demo for a specific feature is not available, you can refer to the Java example, download the SDK for your language, and test the feature.

More information

The sample code is provided for reference only. To download an SDK for a specific language, see SDK downloads.