Synchronizing data to Simple Message Queue (formerly MNS)
When your application produces messages in ApsaraMQ for RabbitMQ that need to reach downstream consumers on Simple Message Queue (formerly MNS), a sink task bridges the two services without custom code. The sink task reads messages from a RabbitMQ queue, optionally filters and transforms them, and delivers the results to an SMQ queue.
How it works
A sink task connects an ApsaraMQ for RabbitMQ queue to an SMQ queue through a four-stage pipeline:
Source -- Read messages from a RabbitMQ instance, vhost, and queue, with configurable batching.
Filtering (optional) -- Define event patterns to select which messages pass through.
Transformation (optional) -- Apply data cleansing logic such as splitting, mapping, enriching, or dynamic routing via Function Compute.
Sink -- Deliver processed messages to the destination SMQ queue.
Prerequisites
Before you begin, make sure you have:
An ApsaraMQ for RabbitMQ instance in the Running state. See Creating resources
An SMQ queue in the target region. See Activate SMQ and authorize RAM users to access SMQ
EventBridge activated with required Resource Access Management (RAM) permissions granted. See Activate EventBridge and grant permissions
Supported regions
SMQ is available as a sink in the following regions:
| Area | Regions |
|---|---|
| China | China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Shenzhen), China (Chengdu), China (Hong Kong) |
| Asia Pacific | Singapore, Japan (Tokyo), Malaysia (Kuala Lumpur), Indonesia (Jakarta) |
| Americas | US (Silicon Valley), US (Virginia) |
| Europe | Germany (Frankfurt) |
Create a sink task
Log on to the ApsaraMQ for RabbitMQ console.
In the left-side navigation pane, choose Connector Ecosystem Integration > Tasks.
In the top navigation bar, select a region, such as China (Hangzhou).
On the Tasks page, click Create Task.
Enter a Task Name and Description, then configure the pipeline stages described in the following sections.
After you finish all stages, click Save.
Configure the source
In the Source step, set Data Provider to ApsaraMQ for RabbitMQ and configure the following parameters. Click Next when finished.
| Parameter | Description | Example |
|---|---|---|
| Region | The region you selected in step 3. This value cannot be changed. | China (Hangzhou) |
| RabbitMQ Instance | The source ApsaraMQ for RabbitMQ instance that produces messages. | amqp-cn-\*\*\*\*\*\*lpc00a |
| vhost | The vhost on the source instance. | test |
| Queue | The queue on the source instance to read messages from. | queue_test |
| Messages | Maximum number of messages per batch. The system waits until this count is reached before sending. Valid values: 1 to 10000. | 100 |
| Interval (Unit: Seconds) | How often the system aggregates and sends messages. Valid values: 0 to 15. Set to 0 for immediate delivery without waiting. | 3 |
Configure event filtering (optional)
In the Filtering step, set Pattern Content to define which events pass through. Only messages matching the specified pattern are forwarded.
For syntax details, see Event patterns.
Configure data transformation (optional)
In the Transformation step, set up data cleansing rules for operations such as splitting, mapping, enriching, and dynamic routing.
For more information, see Use Function Compute for message data cleansing.
Configure the sink
In the Sink step, set Service Type to Message Service MNS and configure the following parameters.
| Parameter | Description | Example |
|---|---|---|
| Queue Name | The destination SMQ queue that receives messages from the source. | test |
| Enable Base64 Encoding | Whether to Base64-encode message data before delivery. Select Yes to encode or No to skip encoding. | Yes |
| Message Body | The transformation type for event content. For more information, see Event content transformation. | Complete Data |
Configure retry and error handling
Configure the retry policy for failed events and how errors are handled. For more information, see Retries and dead-letter queues.
Manage existing tasks
On the Tasks page, find the target task and use the Actions column to perform the following operations:
| Action | Description |
|---|---|
| Details | View the source, sink, and resource configurations on the Message Sink Details page. |
| Edit | Modify the Resource Configuration and Rule Configuration in the Edit Message Sink panel. |
| Enable / Disable | Toggle the task on or off. Click Confirm in the dialog box. |
| Delete | Permanently remove the task. Click Confirm in the dialog box. |
Limitations
Sink tasks are available only in the supported regions listed above.
The source RabbitMQ instance and the sink task must be in the same region.