All Products
Search
Document Center

ApsaraMQ for MQTT:Manage rules for client status notifications

Last Updated:Mar 11, 2026

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.

Note

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.

Client status notification event flow

How it works

  1. An ApsaraMQ for MQTT client connects to or disconnects from the broker.

  2. The broker generates a status notification event based on the configured rule.

  3. The event is forwarded to the specified ApsaraMQ for RocketMQ topic.

  4. Backend services deployed on Elastic Compute Service (ECS) instances subscribe to the RocketMQ topic and process the notifications.

Note

For details about the message structure of forwarded events, see Message structure mappings between Message Queue for MQTT and Message Queue for Apache RocketMQ.

Quotas and limits

ItemLimitDescription
Rules per instance100To request a higher quota, join DingTalk group 35228338 to contact ApsaraMQ for MQTT technical support.
Rule deduplicationOne rule of the same type per internal resourceEach group ID supports only one client status notification rule. Each ApsaraMQ for MQTT topic supports one data inbound rule and one data outbound rule.
Cross-region restrictionData source and destination must be in the same regionFor example, if the data source is an ApsaraMQ for MQTT instance in the China (Hangzhou) region, the destination must also be in the China (Hangzhou) region.
ApsaraMQ for MQTT instance versionV3.x.x kernel requiredCheck the kernel version in the instance list or on the Instance Details page in the ApsaraMQ for MQTT console.
ApsaraMQ for RocketMQ instance version4.0 onlyData exchange rules between ApsaraMQ for MQTT and ApsaraMQ for RocketMQ require ApsaraMQ for RocketMQ 4.0 instances.

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:

  1. Log on to the ApsaraMQ for MQTT console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar, select the region where your instance resides. Click the instance name to go to the Instance Details page.

  3. In the left-side navigation pane, click Rules. In the upper-left corner of the page, click Create Rule.

  4. In the Configure Basic Information step, set the following parameters, then click Next.

    ParameterExampleDescription
    Rule ID111111Globally 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.
    Descriptionmigrate from rocketmqDescription of the rule.
    StatusEnableWhether to enable the rule immediately. Valid values: Enable, Disable.
    Rule TypeClient Status NotificationSelect 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).
  5. In the Configure Rule Source step, set the data source, then click Next.

    ParameterExampleDescription
    Group IDGID_Client_StatusGroup ID of the devices whose status events are forwarded. For more information about group IDs, see Terms.
  6. In the Configure Rule Destination step, set the destination for the forwarded events, then click Create.

    ParameterExampleDescription
    Destination Service TypeMessage Queue for Apache RocketMQCloud service that receives the status events. Only ApsaraMQ for RocketMQ is supported.
    Message Queue for Apache RocketMQ InstanceMQ_INST_13801563067\*\*\*\*\*_BbyOD2jQApsaraMQ for RocketMQ instance that receives the events. Must be in the same region as the MQTT instance.
    TopicTopicBRocketMQ topic that receives the notification events.

After the rule is created, it appears on the Rules page.

Edit a rule

  1. On the Rules page, find the target rule. In the Actions column, choose More > Edit.

  2. On the Edit Rule page, modify any parameter except Rule ID.

  3. Click Save in the Configure Rule Destination step.

Enable or disable a rule

  1. On the Rules page, find the target rule. In the Actions column, choose More > Enable or Disable.

  2. In the confirmation dialog box, click OK.

Delete a rule

  1. On the Rules page, find the target rule. In the Actions column, choose More > Delete.

  2. In the confirmation dialog box, click OK.

Related topics