This section describes how to manage rules for client status notification in the Message Queue for MQTT console.

Background information

When a Message Queue for MQTT client comes online or goes offline, the Message Queue for MQTT broker pushes a client status notification to an Alibaba Cloud service based on the rule that you configured. Backend service applications deployed on Elastic Compute Service (ECS) instances can subscribe to client status notifications from the Alibaba Cloud service to receive notifications when Message Queue for MQTT clients come online or go offline. Notifications of offline and online events

Limits

For more information, see Rule-related limits.

Create a rule for client status notification

  1. Log on to the Message Queue for MQTT console.
  2. In the left-side navigation pane, click Instances.
  3. In the top navigation bar, select a region.
  4. Find the instance for which you want to create a data outbound rule in the instance list. In the Actions column, choose More > Rules.
  5. In the upper-left corner of the Rules page, click Create Rule.
  6. On the Create Rule page, perform the following steps:
    1. In the Configure Basic Information step, set the following parameters and click Next.
      Parameter Example Description
      Rule ID 111111 The global unique identifier of the rule.
      • It can contain only letters, digits, hyphens (-), and underscores (_) and must contain at least one letter or digit.
      • It must be 3 to 64 characters in length. If the value contains more than 64 characters, it is automatically truncated.
      • It cannot be updated after the rule is created.
      Description migrate from rocketmq The description of the rule.
      Status Enable Specifies whether to enable the current rule. Valid values:
      • Enable
      • Disable
      Rule Type Client Status Notification The type of the rule. Valid values:
    2. In the Configure Rule Source step, specify the data source and click Next.
      Parameter Example Description
      Group ID GID_Client_Status The group ID of the devices from which the status event data is exported. For more information about group IDs, see Terms.
    3. In the Configure Rule Destination step, specify the destination to which the data is forwarded and click Create.
      Parameter Example Description
      Destination Service Type Message Queue for Apache RocketMQ The cloud service to which you want to forward the status event data of a Message Queue for MQTT client.
      Note Only Message Queue for Apache RocketMQ is supported.
      Message Queue for Apache RocketMQ Instance MQ_INST_13801563067*****_BbyOD2jQ The ID of the Message Queue for Apache RocketMQ instance to which the data is forwarded.
      Note You can select only an instance that resides in the same region as the Message Queue for MQTT instance.
      Topic TopicB The Message Queue for Apache RocketMQ topic to which the data is forwarded. In this example, the notifications about the online or offline events of a Message Queue for MQTT client are forwarded to TopicB.
    You can view the client status notification rule that you create on Rules page.
Note For more information about the message structure mappings between Message Queue for MQTT and Message Queue for Apache RocketMQ, see Message structure mappings between Message Queue for MQTT and Message Queue for Apache RocketMQ.

Edit a rule for client status notification

  1. Log on to the Message Queue for MQTT console.
  2. In the left-side navigation pane, click Instances.
  3. In the top navigation bar, select the region where your instance is located.
  4. Find the instance for which you want to create a data outbound rule in the instance list. In the Actions column, choose More > Rules.
  5. In the rule list, find the rule that you want to edit. In the Actions column, choose More > Edit.
  6. On the Edit Rule page, you can change all parameter values except the rule ID.
  7. After you change parameter values as needed, click Save in the Configure Rule Destination step.

Delete a rule for client status notification

  1. Log on to the Message Queue for MQTT console.
  2. In the left-side navigation pane, click Instances.
  3. In the top navigation bar, select the region where your instance is located.
  4. Find the instance for which you want to create a data outbound rule in the instance list. In the Actions column, choose More > Rules.
  5. In the rule list, find the rule that you want to delete. In the Actions column, choose More > Delete.
  6. In the message that appears, click OK.

Enable a rule for client status notification

  1. Log on to the Message Queue for MQTT console.
  2. In the left-side navigation pane, click Instances.
  3. In the top navigation bar, select the region where your instance is located.
  4. Find the instance for which you want to create a data outbound rule in the instance list. In the Actions column, choose More > Rules.
  5. In the rule list, find the rule that you want to enable. In the Actions column, choose More > Enable.
  6. In the message that appears, click OK.

Disable a rule for client status notification

  1. Log on to the Message Queue for MQTT console.
  2. In the left-side navigation pane, click Instances.
  3. In the top navigation bar, select the region where your instance is located.
  4. Find the instance for which you want to create a data outbound rule in the instance list. In the Actions column, choose More > Rules.
  5. In the rule list, find the rule that you want to disable. In the Actions column, choose More > Disable.
  6. In the message that appears, click OK.