When MQTT clients connect or disconnect, your backend applications often need real-time visibility into these events for session management, audit logging, or failover handling. Client status notification rules forward these online and offline events from ApsaraMQ for MQTT to an ApsaraMQ for RocketMQ topic, where backend services can consume them.
Only ApsaraMQ for RocketMQ 4.0 instances are supported as the notification destination. The MQTT instance and the RocketMQ instance must be in the same region.

How it works
An ApsaraMQ for MQTT client connects to or disconnects from the broker.
The broker generates a status notification event based on the configured rule.
The event is forwarded to the specified ApsaraMQ for RocketMQ topic.
Backend services deployed on Elastic Compute Service (ECS) instances subscribe to the RocketMQ topic and process the notifications.
For details about the message structure of forwarded events, see Message structure mappings between Message Queue for MQTT and Message Queue for Apache RocketMQ.
Create a client status notification rule
Before you begin, make sure that you have:
An ApsaraMQ for MQTT instance with kernel version V3.x.x
An ApsaraMQ for RocketMQ 4.0 instance in the same region as your MQTT instance
A RocketMQ topic to receive the notification events
A group ID configured for the MQTT devices you want to monitor
To create a rule, follow these steps:
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 your instance resides. 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 page, click Create Rule.
In the Configure Basic Information step, set the following parameters, then click Next.
Parameter Example Description Rule ID 111111 Globally unique identifier for the rule. Can contain letters, digits, hyphens (-), and underscores (_). Must include at least one letter or digit, and be 3 to 64 characters long. Values exceeding 64 characters are automatically truncated. Cannot be changed after creation. Description migrate from rocketmq Description of the rule. Status Enable Whether to enable the rule immediately. Valid values: Enable, Disable. Rule Type Client Status Notification Select Client Status Notification to forward client online and offline events. Other valid values: Data Outbound (see Export data from ApsaraMQ for MQTT to other Alibaba Cloud services), Data Inbound (see Import data from other cloud services to ApsaraMQ for MQTT). In the Configure Rule Source step, set the data source, then click Next.
Parameter Example Description Group ID GID_Client_Status Group ID of the devices whose status events are forwarded. For more information about group IDs, see Terms. In the Configure Rule Destination step, set the destination for the forwarded events, then click Create.
Parameter Example Description Destination Service Type Message Queue for Apache RocketMQ Cloud service that receives the status events. Only ApsaraMQ for RocketMQ is supported. Message Queue for Apache RocketMQ Instance MQ_INST_13801563067\*\*\*\*\*_BbyOD2jQ ApsaraMQ for RocketMQ instance that receives the events. Must be in the same region as the MQTT instance. Topic TopicB RocketMQ topic that receives the notification events.
After the rule is created, it appears on the Rules page.
Edit a rule
On the Rules page, find the target rule. In the Actions column, choose More > Edit.
On the Edit Rule page, modify any parameter except Rule ID.
Click Save in the Configure Rule Destination step.
Enable or disable a rule
On the Rules page, find the target rule. In the Actions column, choose More > Enable or Disable.
In the confirmation dialog box, click OK.
Delete a rule
On the Rules page, find the target rule. In the Actions column, choose More > Delete.
In the confirmation dialog box, click OK.