Alibaba Cloud Internet of Things platform business topic planning best practice
Alibaba Cloud Internet of Things platform business topic planning best practice
When we do business development based on Alibaba Cloud's Internet of Things platform, the most critical question is: how to reasonably plan the topic and Payload of business communication?
basic principle:
• Topic has clear operation authority: publish/subscribe, and avoid using publish and subscribe.
• Topic and Payload formats correspond one by one to avoid one topic corresponding to multiple Payload formats.
• Topic carries clear uplink and downlink identifiers, such as up and down
Topic of the same type of business carries the same identifier for sorting
Next, we will take the shared Alipay business scenario as an example to show you the best practice of Topic planning.
1. Business Topic Planning
The business in the charging bank scenario involves the status of the charging bank cabinet, the borrowing and returning of the charging bank by consumers, the advertising business and other scenarios. The topic plan is as follows:
1.1 Equipment Reporting Scenario
• The current attribute status of the equipment is reported regularly, including voltage, current, card slot status and temperature
• Advertising broadcast information report, including the current advertising resource ID,
• Abnormal event reporting, including the ejection and return of the charging bank, voltage overload, and empty card slot
1.2 Cloud Downlink Command Scenario
• Pop up the power bank
• Update advertising information
1.3 Change of cabinet online status
• When the cabinet is online/offline, the IoT platform will trigger the status change topic
2. Rule Engine Configuration
Through rule engine configuration, we realize the flow of different types of business messages:
2.1 Circulation of abnormal events
Abnormal events flow to function calculation for real-time business processing.
Business processing SQL:
SELECT
*, -- Payload complete content
DeviceName() as deviceName, -- device id
Attribute ('bizId ') as bizId, -- business channel ID
timestamp ('yyyy MM dd HH: mm: ss') as time -- current time
Topic () as topic -- current topic
FROM
"/a1WHdPQzUUn/+/user/up/event/#" -- all uplink events
Data flow:
2.2 Advertising broadcast statistics
The advertisement playing record is stored in the form for subsequent offline business analysis
Business processing SQL:
SELECT
*, -- Payload complete content
DeviceName() as deviceName, -- device id
Attribute ('bizId ') as bizId, -- business channel ID
timestamp ('yyyy MM dd HH: mm: ss') as time -- current time
FROM
"/a1WHdPQzUUn/+/user/up/ad/play" -- advertisement broadcast message
Data flow:
2.3 Equipment status flow
The advertisement playing record is stored in the form for future business query
Business processing SQL:
SELECT
*, -- Payload complete content
DeviceName() as deviceName, -- device id
Attribute ('bizId ') as bizId, -- business channel ID
timestamp ('yyyy MM dd HH: mm: ss') as time -- current time
FROM
"/a1WHdPQzUUn/+/user/up/property/post" -- status attribute reporting
Data flow:
2.4 Online status flow of cabinet
Topic format of online/offline status flow of equipment:
/as/mqtt/status/{productKey}/{deviceName}
Payload data format:
{
"status":"online|offline",
"productKey":"pk13543",
"deviceName":"dn1234",
"time":"2018-08-31 15:32:28.205",
"utcTime":"2018-08-31T07:32:28.205Z",
"lastTime":"2018-08-31 15:32:28.195",
"utcLastTime":"2018-08-31T07:32:28.195Z",
"clientIp":"123.123.123.123"
}
Rule Engine SQL:
SELECT productKey,deviceName,
timestamp() as timestamp ,
status,
time as currentTime ,lastTime,clientIp
FROM "/as/mqtt/status/a1WHdPQzUUn/+"
When we do business development based on Alibaba Cloud's Internet of Things platform, the most critical question is: how to reasonably plan the topic and Payload of business communication?
basic principle:
• Topic has clear operation authority: publish/subscribe, and avoid using publish and subscribe.
• Topic and Payload formats correspond one by one to avoid one topic corresponding to multiple Payload formats.
• Topic carries clear uplink and downlink identifiers, such as up and down
Topic of the same type of business carries the same identifier for sorting
Next, we will take the shared Alipay business scenario as an example to show you the best practice of Topic planning.
1. Business Topic Planning
The business in the charging bank scenario involves the status of the charging bank cabinet, the borrowing and returning of the charging bank by consumers, the advertising business and other scenarios. The topic plan is as follows:
1.1 Equipment Reporting Scenario
• The current attribute status of the equipment is reported regularly, including voltage, current, card slot status and temperature
• Advertising broadcast information report, including the current advertising resource ID,
• Abnormal event reporting, including the ejection and return of the charging bank, voltage overload, and empty card slot
1.2 Cloud Downlink Command Scenario
• Pop up the power bank
• Update advertising information
1.3 Change of cabinet online status
• When the cabinet is online/offline, the IoT platform will trigger the status change topic
2. Rule Engine Configuration
Through rule engine configuration, we realize the flow of different types of business messages:
2.1 Circulation of abnormal events
Abnormal events flow to function calculation for real-time business processing.
Business processing SQL:
SELECT
*, -- Payload complete content
DeviceName() as deviceName, -- device id
Attribute ('bizId ') as bizId, -- business channel ID
timestamp ('yyyy MM dd HH: mm: ss') as time -- current time
Topic () as topic -- current topic
FROM
"/a1WHdPQzUUn/+/user/up/event/#" -- all uplink events
Data flow:
2.2 Advertising broadcast statistics
The advertisement playing record is stored in the form for subsequent offline business analysis
Business processing SQL:
SELECT
*, -- Payload complete content
DeviceName() as deviceName, -- device id
Attribute ('bizId ') as bizId, -- business channel ID
timestamp ('yyyy MM dd HH: mm: ss') as time -- current time
FROM
"/a1WHdPQzUUn/+/user/up/ad/play" -- advertisement broadcast message
Data flow:
2.3 Equipment status flow
The advertisement playing record is stored in the form for future business query
Business processing SQL:
SELECT
*, -- Payload complete content
DeviceName() as deviceName, -- device id
Attribute ('bizId ') as bizId, -- business channel ID
timestamp ('yyyy MM dd HH: mm: ss') as time -- current time
FROM
"/a1WHdPQzUUn/+/user/up/property/post" -- status attribute reporting
Data flow:
2.4 Online status flow of cabinet
Topic format of online/offline status flow of equipment:
/as/mqtt/status/{productKey}/{deviceName}
Payload data format:
{
"status":"online|offline",
"productKey":"pk13543",
"deviceName":"dn1234",
"time":"2018-08-31 15:32:28.205",
"utcTime":"2018-08-31T07:32:28.205Z",
"lastTime":"2018-08-31 15:32:28.195",
"utcLastTime":"2018-08-31T07:32:28.195Z",
"clientIp":"123.123.123.123"
}
Rule Engine SQL:
SELECT productKey,deviceName,
timestamp() as timestamp ,
status,
time as currentTime ,lastTime,clientIp
FROM "/as/mqtt/status/a1WHdPQzUUn/+"
Related Articles
-
A detailed explanation of Hadoop core architecture HDFS
Knowledge Base Team
-
What Does IOT Mean
Knowledge Base Team
-
6 Optional Technologies for Data Storage
Knowledge Base Team
-
What Is Blockchain Technology
Knowledge Base Team
Explore More Special Offers
-
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