Overview

更新时间:
复制 MD 格式

Many companies are migrating their Internet of Things (IoT) devices to the cloud. This document provides a solution for migrating from a self-managed Message Queuing Telemetry Transport (MQTT) cluster to Alibaba Cloud IoT Platform.

Background information

As IoT businesses grow and the number of devices increases, self-managed MQTT clusters face new challenges:

  • Connection stability decreases, and devices frequently go offline.
  • High message latency causes slow service responses and customer complaints.
  • Servers require scaling out, which increases hardware and Operations and Maintenance (O&M) costs.

Migrating device connections to the secure, stable, low-latency, high-availability (HA), and fully managed Alibaba Cloud IoT Platform is the best solution to these challenges.

This document uses an electricity meter scenario as an example to describe the solution for migrating from a self-managed MQTT cluster to Alibaba Cloud IoT Platform.

Current system

Assume a company has 100,000 devices connected to a self-managed MQTT cluster. The service architecture is shown in the following figure.

业务架构

Devices report business data to the MQTT cluster every 15 minutes. The data is forwarded in real time to Kafka. A business system consumes the data from Kafka, processes it based on business logic, and then stores it in a database. If specific conditions are met, the system sends a real-time text message to O&M engineers. Administrators use a mobile app to send configuration parameters to the business system. The business system then calls API operations on the MQTT cluster to push configuration instructions to the devices.

The uplink data and downlink instructions based on the MQTT protocol are defined as follows:

ScenarioCommunication TopicMessage Payload
Device data reportingcdb/data/postDE02,10,17,011101010,am024,1d478f
Server-side control instructioncdb/cmd/pushCMD,82923,ad322

Solution design

This solution is designed to reduce modification costs and disruption to the existing system. It allows for a quick, low-cost migration of devices to IoT Platform without changing the message format. This approach helps maintain the stability of the cloud-based business system and reduces infrastructure costs.

设备上云

The solution involves three core changes for migrating IoT devices to the cloud:

  • Perform an over-the-air (OTA) update on the devices to change the access domain name to the IoT Platform endpoint.
  • Configure the rules engine to forward device data to a server-side subscription Advanced Message Queuing Protocol (AMQP) consumer group. The business server then receives device data in real time.
  • Map the topics from the self-managed MQTT cluster to the custom topics of IoT Platform, as shown in the following table.
Table 1. Topic mapping solution
Original TopicOriginal Message PayloadMigrated Custom TopicMigrated PayloadPermissionDescription
cdb/data/postDE02,10,17,011101010,am024,1d478f/${productKey}/${deviceName}/user/data/upThe format is unchanged. It is still DE02,10,17,011101010,am024,1d478fPublishThe device reports data to the cloud.
cdb/cmd/pushCMD,82923,ad322/${productKey}/${deviceName}/user/cmd/downThe format is unchanged. It is still CMD,82923,ad322SubscribeThe cloud sends instructions to the device.

Procedure

  1. In the IoT Platform console, configure the product, device, topics, and data forwarding solution. For more information, see Cloud-side development.
  2. Develop the business logic on the device side. For more information, see Device-side development.
  3. Develop the business logic on the server side to receive device data and send control instructions. For more information, see Server-side development.
  4. Start the server-side program, connect to IoT Platform, and perform joint commissioning. For more information, see Joint commissioning.