When an ApsaraMQ for MQTT client comes online or goes offline, the ApsaraMQ 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 ApsaraMQ for MQTT clients come online or go offline.
Process
Create a rule for client status notifications
Log on to the ApsaraMQ for MQTT console. In the left-side navigation pane, click Instances.
In the top navigation bar, select the region where the instance that you want to manage resides. On the Instances page, click the instance name to go to the Instance Details page.
In the left-side navigation pane, click Rules. In the upper-left corner of the Rules page, click Create Rule.
On the Create Rule page, perform the following steps:
In the Configure Basic Information step, configure the following parameters and click Next.
Parameter
Example
Description
Rule ID
111111
The ID of the rule. An ID is a globally unique identifier of a rule.
A rule ID can contain only letters, digits, hyphens (-), and underscores (_) and must contain at least one letter or digit.
A rule ID must be 3 to 64 characters in length. If the value contains more than 64 characters, it is automatically truncated.
The ID of a rule 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:
Data Outbound: The rule is used to export data from ApsaraMQ for MQTT to other Alibaba Cloud services. For more information, see Export data from ApsaraMQ for MQTT to other Alibaba Cloud services.
Data Inbound: The rule is used to import data from other Alibaba Cloud services to ApsaraMQ for MQTT. For more information, see Import data from other cloud services to ApsaraMQ for MQTT.
Client Status Notification: The rule is used to export the data for online and offline events of ApsaraMQ for MQTT clients to other Alibaba Cloud services. For more information, see Export online and offline events of Message Queue for MQTT clients.
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 event data is exported. For information about group IDs, see Terms.
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 event data of a ApsaraMQ for MQTT client.
NoteOnly ApsaraMQ for RocketMQ is supported.
Message Queue for Apache RocketMQ Instance
MQ_INST_13801563067*****_BbyOD2jQ
The ID of the ApsaraMQ for RocketMQ instance to which the data is forwarded.
NoteYou can select only an instance that resides in the same region as the ApsaraMQ for MQTT instance.
Topic
TopicB
The ApsaraMQ for RocketMQ topic to which the data is forwarded. In this example, the notifications about the online or offline events of a ApsaraMQ for MQTT client are forwarded to Topic B.
You can view the client status notification rule that you create on Rules page.
Edit a rule for client status notifications
In the rule list, find the rule that you want to edit. In the Actions column, choose .
On the Edit Rule page, you can change all parameter values except the rule ID.
After you change the parameter values, click Save in the Configure Rule Destination step.
Delete a rule for client status notifications
In the rule list, find the rule that you want to delete. In the Actions column, choose .
In the message that appears, click OK.
Enable a rule for client status notifications
In the rule list, find the rule that you want to enable. In the Actions column, choose .
In the message that appears, click OK.
Disable a rule for client status notifications
In the rule list, find the rule that you want to disable. In the Actions column, choose .
In the message that appears, click OK.