All Products
Search
Document Center

Link IoT Edge:Configure message routing

Last Updated:Aug 03, 2023

Message routing dynamically adjusts how data flows based on routing rules. Message routing allows you to route messages that meet the specified filter conditions from the source to the destination.

Prerequisites

An edge instance in which you can configure message routing is created. The edge instance is assigned with a gateway, drivers, devices, and edge applications.

Procedure

  1. Log on to the Link IoT Edge console.
  2. In the left-side navigation pane, click Edge Instances.
  3. Find the edge instance in which you want to configure message routing, and click View in the Actions column.
  4. On the Instance Details page, click the Message Routing tab, and click Assign Route. Assign Message Route dialog box
  5. In the Assign Message Route dialog box, set the parameters as required to assign a message route. After the setting is complete, click OK.
    ParameterDescription
    Route NameThe name of the message route. The name must be 4 to 32 characters in length.
    Message Source

    The source of messages. Valid values:

    • Device: indicates that messages are sent from the devices that are assigned to the edge instance.
      • All Products: indicates that messages are sent from all the devices that are assigned to the edge instance.
      • All Devices: indicates that messages are sent from the devices of a specific product. The devices are assigned to the edge instance.
      • You can also specify the product name and DeviceName. In this case, messages are sent from the specified device.
    • Edge Applications: indicates that messages are sent from the edge application. You must select an edge application that is assigned to the edge instance.
      Note You can select only the edge applications that are created by using Function Compute.
    • IoT Hub: indicates that messages are sent from the cloud.
      If you select this option, the following custom topic category must be created for the gateway. We recommend that you check whether the topic category is created for the gateway. If the topic category is not created, create the topic category first. For more information, see Use custom topics.
      • The YourProductKey/${deviceName}/user/# custom topic category must be created. In this topic category, the YourProductKey variable indicates your ProductKey, and the ${deviceName} variable indicates your DeviceName.
      • In the topic category settings, you must set the Device Operation Authorizations parameter to Subscribe.
    Message Topic Filter

    The filter condition of messages. Only the messages that meet the specified filter condition can be sent to the message destination. Specify the parameter in the following ways:

    • If you set the Message Source parameter to Device, select Property, Event, or All.
    • If you set the Message Source parameter to Edge Applications, specify a custom topic category. For information about how to create a custom topic category, see What is a topic? You can use the plus sign (+) and number sign (#) as wildcards when you create a custom topic category.
    • If you set the Message Source parameter to IoT Hub, select a topic category from the drop-down list. Messages that belong to the topic category are sent to the message destination.
    Message Destination

    The destination of messages. Valid values:

    • IoT Hub: indicates that the messages are sent to the cloud. If you select this option, you must specify a service level. For more information, see the description of the Service Level parameter.
    • Edge Applications: indicates that the messages are sent to the specified edge application. If you select this option, you must specify an edge application.
      Note You can select only the edge applications that are created by using Function Compute.
    Service Level

    The level of the service. This parameter is available only when you set the Message Source parameter to IoT Hub. This parameter specifies whether to resume data transmission from a breakpoint. Valid values:

    • 0: indicates that data transmission is not resumed from a breakpoint. Messages fail to be sent to the cloud if network errors occur.
    • 1: indicates that data transmission is resumed from a breakpoint. If network errors occur, the messages that need to be sent to the cloud are stored in a local storage location. After network connections are reestablished, Link IoT Edge sends the historical data in the local storage location to the cloud.

      If you specify a message route that starts from an edge application and ends with IoT Hub, and you select 1 for this parameter, you must create the following custom topic category for the gateway. For more information, see Use custom topics. After the custom topic category is created, you must restart the gateway.

      • The /YourProductKey/YourDeviceName/user/restore custom topic category must be created. In this topic category, you must specify the YourProductKey and YourDeviceName variables based on the information about your device certificate.
      • In the topic category settings, you must set the Device Operation Authorizations parameter to Subscribe.
      You can send the historical data that failed to be sent to the cloud due to network errors by using this topic category. You can use the rules engine in the cloud to classify and process the historical data. The following code describes the format of the historical data:
      { "topic":"yyyyy", "payload":.... #STRING type or OBJECT type }

      In this format, the topic element indicates the original topic of the data that is to be sent to the cloud, and the payload element indicates the data that is to be sent to the cloud.

    Note If you select 1 for this parameter, data transmission can be resumed from a breakpoint. If network errors occur, the consumed CPU and disk I/O resources increase. All the available CPU and disk I/O resources may be consumed if you resume the transmission of large amounts of data. The upper limit for processing workloads varies based on the system performance. We recommend that you specify this parameter based on your business requirements.
    Note
    • If message routes have the same settings for the Message Source and Message Destination parameters but different settings for the Message Topic Filter parameter, each message is sent once at most. That is, if a message has been sent by using one of the routes, the system stops matching other routes.
    • If message routes have different settings for the Message Source or Message Destination parameter, messages are sent by using all the message routes.

      Messages may be repeatedly sent. Assume that you specify two message routes. For one of the message routes, the message source is all devices and the message destination is IoT Hub. For the other message route, the message source is Device A and the message destination is IoT Hub. If Device A sends a message to the cloud, the message is sent twice by using the two routes.