This topic describes the topic alias feature of MQTT 5.0.
Background information
Most IoT devices that are connected to IoT Platform over cellular networks are sensitive to traffic and power consumption. For example, the traffic of temperature sensors that are used in agriculture scenarios and powered by batteries is limited to several megabytes each month. In this case, a smaller packet that is used to transmit data can reduce power and traffic consumption. You can use topic aliases to replace topic names with numbers to reduce the length of a data packet that contains a message. In most cases, a topic name that contains business properties can be dozens of bytes in length and can exceed the length of a payload. You can use topic aliases to replace a topic name with a number that is only four bytes in length.
Limits
Topic aliases work based on mappings between topic names and aliases. Devices and IoT Platform must maintain the corresponding mappings. A mapping is created the first time a device uses an alias to send messages and is deleted when the device is disconnected. A mapping is created between a topic name and an alias each time a device reconnects to IoT Platform and uses the corresponding topic to send messages.
Each alias must be unique. An alias corresponds to only one topic name.
If you use a topic alias, do not concurrently publish messages. Otherwise, messages that are concurrently published may be lost due to the distributed architecture of IoT Platform.
IoT Platform allows you to specify up to 20 topic aliases and send up to 20 downstream or upstream messages by using a topic alias.
Scenarios
The following figure shows how to use a topic alias. In this example, a temperature sensor is used. In this example, the payloads of Message A and Message B are the same. A topic name and an alias are specified for Message A and only a topic alias is specified for Message B. The name of the /sys/product_name/device_001/farmland_1234/sensors/temperature
topic exceeds 60 bytes in length. A topic alias saves a specific volume of traffic.