This topic describes how to create a message outflow task in the ApsaraMQ for MQTT console to synchronize data from an ApsaraMQ for MQTT instance to an ApsaraMQ for RabbitMQ instance.
Prerequisites
An ApsaraMQ for MQTT instance is purchased and deployed. Make sure that the instance is in the Running state. For more information, see Create resources.
An ApsaraMQ for RabbitMQ instance is purchased and deployed. Make sure that the instance is in the Running state. For more information, see Step 2: Create resources.
EventBridge is activated and the required permissions are granted to a Resource Access Management (RAM) user. For more information, see Activate EventBridge and grant permissions to a RAM user.
Create a message outflow task
Log on to the ApsaraMQ for MQTT console. In the left-side navigation pane, choose .
In the top navigation bar, select a region, such as China (Hangzhou). On the Tasks page, click Create Task.
In the Create Task page, configure the Task Name and Description parameters. Then, follow the on-screen instructions to configure other parameters. The following section describes the parameters:
Task Creation
In the Source step, set the Data Provider parameter to Message Queue for MQTT and follow the on-screen instructions to configure other parameters. Then, click Next Step. The following table describes the parameters.
Parameter
Description
Example
Region
The region where the ApsaraMQ for MQTT instance resides. The region that you selected when you created the instance is automatically filled.
China (Hangzhou)
MQTT Instance
The ApsaraMQ for MQTT instance in which the messages that you want to route are produced.
post-cn-jajh8i****
MQTT Topic
The topic on the ApsaraMQ for MQTT instance in which the messages that you want to route are produced.
test-topic
Data Format
The data format feature is used to encode binary data delivered from the source into a specific data format. Multiple data formats are supported. If you do not have special requirements on encoding, specify JSON as the value.
JSON: Binary data is encoded into JSON-formatted data based on UTF-8 encoding and then put into the payload. This is the default value.
Text: Binary data is encoded into strings based on UTF-8 encoding and then put into the payload.
Binary: Binary data is encoded into strings based on Base64 encoding and then put into the payload.
JSON
Batch Push
The batch push feature helps you aggregate multiple events at a time. This feature is triggered if the condition that is specified by the Messages parameter or the Interval (Unit: Seconds) parameter is met.
For example, if you set the Messages parameter to 100 and the Interval (Unit: Seconds) parameter to 15, the push is executed when the number of messages reaches 100 even if only 10 seconds are elapsed.
None
Messages
The maximum number of messages that can be sent in each function invocation. Requests are sent only when the number of messages in the backlog reaches the specified value. Valid values: 1 to 10000.
100
Interval (Unit: Seconds)
The time interval at which the function is invoked. The system sends the aggregated messages to Function Compute at the specified time interval. Valid values: 0 to 15. Unit: seconds. The value 0 specifies that messages are sent immediately after aggregation.
3
In the Filtering step, define a data pattern in the Pattern Content code editor to filter requests. For more information, see Event patterns.
In the Transformation step, specify a data cleansing method to implement data processing capabilities such as splitting, mapping, enrichment, and dynamic routing. For more information, see Data cleansing.
In the Sink step, set the Service Type parameter to Message Queue for RabbitMQ and follow the on-screen instructions to configure other parameters. The following table describes the parameters.
Parameter
Description
Example
Instance ID
The ApsaraMQ for RabbitMQ instance that you created.
amqp-cn-zvp2pny6****
vhost
The vhost that you created.
test
Destination Type
Exchange: A producer sends a message to an exchange, and then the exchange routes the message to one or more queues.
Queue: Each message is sent to one or more queues.
Queue
Exchange
The exchange to which events are routed on the ApsaraMQ for RabbitMQ instance. This parameter is required only if you set the Destination Type parameter to Exchange.
exchange
Queue
The queue to which events are routed on the ApsaraMQ for RabbitMQ instance. This parameter is required only if you set the Destination Type parameter to Queue.
queue
Message Routing Key
EventBridge extracts data from an event by using JSONPath and routes the specified event content to the event target. This parameter is required only if you set the Destination Type parameter to Exchange.
Data Extraction
$.data.keyMessage Body
EventBridge extracts data from an event by using JSONPath and routes the specified content of the event to the event target.
Data Extraction
$.data.bodyMessageId
EventBridge extracts data from an event by using JSONPath and routes the specified content of the event to the event target.
Data Extraction
$.data.props.messageIdEventBridge extracts data from an event by using JSONPath and routes the specified content of the event to the event target.
Data Extraction
$.data.props
Task Property
Configure the retry policy that is used when events fail to be pushed and the method that is used to handle faults. For more information, see Retry policies and dead-letter queues.
Go back to the Tasks page, find the message outflow task that you created, and then click Enable in the Actions column.
In the Note message, click OK.
The task requires 30 to 60 seconds to be enabled. You can view the progress in the Status column on the Tasks page.
Other operations
On the Tasks page, find the message outflow task that you want to manage and perform other operations in the Actions column.
View the task details: Click Details in the Actions column. On the Task Details page, view the basic information, properties, and monitoring metrics of the task.
Modify the task configurations: Click Edit in the Actions column. In the Edit Task panel, modify the details and properties of the task.
Enable or disable the task: Click Enable or Pause in the Actions column. In the Note message, click OK.
Delete the task: Click Delete in the Actions column. In the Note message, click OK.