Data outbound rules forward messages published to ApsaraMQ for MQTT topics to other Alibaba Cloud services. After a rule is active, messages are automatically delivered to the destination service and can be consumed through its API. Currently, only ApsaraMQ for RocketMQ 4.0 is supported as a destination.

How it works
When you create a data outbound rule, you specify a source MQTT topic and a destination RocketMQ topic. ApsaraMQ for MQTT continuously forwards all messages published to the source topic to the destination topic. You can then consume these messages through the ApsaraMQ for RocketMQ API.
ApsaraMQ for MQTT supports multi-level topics, but ApsaraMQ for RocketMQ supports only single-level topics. During forwarding, a level-1 MQTT topic maps to a RocketMQ topic, while sub-level MQTT topics map to RocketMQ message properties. For details, see Message structure mappings between ApsaraMQ for MQTT and ApsaraMQ for RocketMQ.
Create a data outbound rule
Before you begin, ensure 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 the MQTT instance
Topics created on both instances
View the kernel version of your MQTT instance in the instance list or on the Instance Details page in the ApsaraMQ for MQTT console.
To create a data outbound rule:
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 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.
In the Configure Basic Information step, set the following parameters and click Next.
Parameter Required Example Description Rule ID Yes 111111 Globally unique identifier. Allowed characters: letters, digits, hyphens (-), and underscores (_). Must include at least one letter or digit. Length: 3 to 64 characters (auto-truncated if longer). Cannot be changed after creation. Description No migrate from rocketmq Description of the rule. Status Yes Enable Whether to enable the rule upon creation. Valid values: Enable, Disable. Rule Type Yes Data Outbound The type of the rule. Valid values: Data Outbound: Forward MQTT messages to another Alibaba Cloud service. For more information, see Export data from ApsaraMQ for MQTT to other Alibaba Cloud services. Data Inbound: 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: Export the status events of ApsaraMQ for MQTT clients to other Alibaba Cloud services. For more information, see Export status events of ApsaraMQ for MQTT clients. In the Configure Rule Source step, specify the source topic and click Next.
ImportantApsaraMQ for MQTT supports multi-level topics, but ApsaraMQ for RocketMQ supports only single-level topics. A level-1 MQTT topic maps to a RocketMQ topic, while sub-level MQTT topics map to RocketMQ message properties. For details, see Message structure mappings between ApsaraMQ for MQTT and ApsaraMQ for RocketMQ.
Parameter Required Example Description Topic Yes Topic A The MQTT topic from which to export data. In the Configure Rule Destination step, specify the destination and click Create.
Parameter Required Example Description Destination Service Type Yes Message Queue for Apache RocketMQ Only ApsaraMQ for RocketMQ is supported. Message Queue for Apache RocketMQ Instance Yes MQ_INST_13801563067\*\*\*\*\*\_BbyOD2jQ The RocketMQ instance ID. Must be in the same region as the MQTT instance. Topic Yes Topic B The destination topic on the RocketMQ instance. Messages from the source MQTT topic are forwarded here.
After the rule is created, it appears on the Rules page.
For information about how MQTT messages map to RocketMQ messages, see Message structure mappings between ApsaraMQ for MQTT and ApsaraMQ for RocketMQ.
Edit a data outbound 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 the rule ID.
Click Save in the Configure Rule Destination step.
Delete a data outbound rule
On the Rules page, find the target rule. In the Actions column, choose More > Delete.
In the confirmation dialog box, click OK.
Enable a data outbound rule
On the Rules page, find the target rule. In the Actions column, choose More > Enable.
In the confirmation dialog box, click OK.
Disable a data outbound rule
On the Rules page, find the target rule. In the Actions column, choose More > Disable.
In the confirmation dialog box, click OK.