Updated on 2023-11-24 GMT+08:00

Edge Nodes Reporting Messages to the Cloud

Scenario

IEF allows edge nodes to report messages to the cloud.

You can publish data to a custom topic in SystemEventBus (MQTT broker) of edge nodes. IEF forwards the data to a DIS stream or an API Gateway address. Then, you can extract the data for processing and analysis.

This section uses the DIS endpoint as an example. The method of using the API Gateway endpoint is similar. The procedure is as follows:

  1. Creating an Endpoint
  2. Buying a DIS Stream
  3. Creating a Route
  4. Sending a Message

Creating an Endpoint

  1. Log in to the IEF console, and click Switch Instance on the Dashboard page to select a platinum service instance.
  2. In the navigation pane, choose Edge-Cloud Messages > Endpoints.
  3. Click Create Endpoint in the upper right corner. Select DIS for Type, and enter an endpoint name.

    Figure 1 Creating an endpoint

  4. Click OK.

Buying a DIS Stream

Before sending messages to DIS, buy a DIS stream.

  1. Log in to the DIS console.
  2. Click Buy Stream in the right corner and set parameters.

    Figure 2 Buying a DIS stream

  3. Click Next, confirm the product specifications, and click Submit.

Creating a Route

  1. Log in to the IEF console, and click Switch Instance on the Dashboard page to select a platinum service instance.
  2. In the navigation pane, choose Edge-Cloud Messages > Routes.
  3. Click Create Route in the upper right corner.
  4. Set parameters.

    Figure 3 Creating a route
    • Name: Enter a route name.

      Message routes and system subscriptions are of the same resource type. Their names cannot conflict with each other.

    • Source Endpoint: Select SystemEventBus.
    • Source Endpoint Resource: Select Custom topic, select the edge node that will send messages, and enter a topic name.
    • Destination Endpoint: Select the endpoint created in Creating an Endpoint.
    • Destination Endpoint Resource: Select the DIS stream purchased in Buying a DIS Stream.
    • Record the topic, as shown in the red box in the preceding figure. After the route is created, you can view the topic in the Source Endpoint column of the route list.
    • After customizing a topic, you need to use the complete topic (marked in red in the figure above) for messaging.

  5. Click Create.

Sending a Message

Use the MQTT client on the edge node to send messages.

In this example, the message needs to be published to the topic specified in Creating a Route. As shown in the following figure, mosquitto_pub is used to send a message.

[root@ief-node ~]# mosquitto_pub -t '05e1aef9040010e22fccc009adecb056/nodes/7092ad14-adee-4a09-b969-1505bbdecef5/user/aaa' -d -m '{ "edgemsg": "msgToCloud"}'
Client mosq-p5LouPQIW2gx0JPkRF sending CONNECT
Client mosq-p5LouPQIW2gx0JPkRF received CONNACK (0)
Client mosq-p5LouPQIW2gx0JPkRF sending PUBLISH (d0, q0, r0, m1, '05e1aef9040010e22fccc009adecb056/nodes/7092ad14-adee-4a09-b969-1505bbdecef5/user/aaa', ... (26 bytes))
Client mosq-p5LouPQIW2gx0JPkRF sending DISCONNECT

After the message is sent, you can view the Forwarded Messages column in the route list to check whether the message is successfully forwarded by the route.

Figure 4 Number of forwarded messages

You can view incoming messages on the DIS console.

Figure 5 DIS data monitoring

Obtaining Data

After data is forwarded to DIS stream, you can extract the data for processing and analysis. For details on how to obtain data from DIS, see Obtaining Data from DIS.