Migration of Alibaba Cloud IoT platform development practice

1、 Background

In the field of the Internet of Things, with the gradual expansion of enterprise business scale, more and more terminal equipment, the cost of self built MQTT clusters' horizontal expansion and continuous operation and maintenance is getting higher and higher. It is urgent to find a highly reliable, safe, low-cost, and maintenance free IoT fully hosted service. At the same time, it is necessary to ensure the zero transformation of existing equipment that has been distributed throughout the country to achieve the migration of MQTT services.

The cloud gateway launched by Alibaba Cloud's Internet of Things platform perfectly solves the stability and scalability bottlenecks encountered by enterprises after their scale expansion. During the migration process, the device side does not need to be changed, and only the mqtt domain name points to the cloud gateway domain name created by Alibaba Cloud's IoT instance.

2、 Overall migration plan

3、 Overall migration steps of inventory equipment

3.1 Opening IoT instance (exclusive)

https://common-buy.aliyun.com/?commodityCode=iot_instc_public_cn#/

3.2 Create Cloud Gateway

In the exclusive enterprise instance, create a cloud gateway. Select the MQTT protocol, select the authentication method according to the situation, and configure the TLS authentication certificate and secret key corresponding to the domain name of the self built MQTT.

Complete documentation: https://help.aliyun.com/document_detail/433804.html

3.3 Registered stock equipment

After the cloud gateway is created, a supporting product will be created: cloud gateway xxx.

Next, we need to register the identity authentication information of the stock equipment under the cloud gateway product.

The CSV format of equipment batch registration is as follows:

After successful registration, Alibaba Cloud IoT can verify the identity of the device connection.

PS: When we have a large number of devices, we can register through API to free our hands!

3.4 Configure the rule engine to realize data flow

In order to achieve real-time data transfer, we need to configure the rule engine in the cloud product flow. It includes three items: data source, data destination, and parser script.

3.4.1 Create Data Source

When creating a data source, we need to register the original reported data topic of our equipment in the data source.

3.4.2 Creating Data Destinations

The data destination refers to the system we use to receive the data reported by the equipment, which can be database, message queue, function calculation, etc. Here we choose AMQP server subscription.

3.4.1 Configuration Resolution Script

In the parser script, we take the message body of the data source and transfer it to the AMQP consumption group. You can also process the data according to business needs before forwarding.

3.5 Modifying CName information at the domain name service provider

After creating a cloud gateway, we will get the URL address of a gateway. At this time, we need to log in to the domain name service provider management background, modify the self built MQTT access domain name and jump to the cloud gateway URL, so that the connections of the stock devices will flow to the cloud gateway of Alibaba Cloud IoT, and the self built MQTT cluster can be offline.

3.6 Automatic Device Migration to Alibaba Cloud IoT

After the domain name adjustment took effect, we observed that the device was successfully connected to the Alibaba Cloud IoT platform, displayed online, and subscribed to a custom topic.

In the log service, the online logs of the device are also observed.

3.7 Equipment report data

After the equipment reports the data, it will flow to the downstream system in real time according to the rule engine configuration. The complete log record is as follows:

We can also visually view the data flow link through the message trace.

In the consumption group subscribed by the server, you can view the message consumption rate, message stacking, consumer list and other information.

3.8 Issue equipment control command

Through the Pub interface of the IoT enterprise instance, we can issue control instructions to the specified device. https://help.aliyun.com/document_detail/69793.htm

In the log service, you can view the log of the control instructions we send to the device.

We can also visually view the data flow link through the message trace.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us