Synchronizing data to Simple Message Queue (formerly MNS)

更新时间:
复制 MD 格式

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:

  1. Source -- Read messages from a RabbitMQ instance, vhost, and queue, with configurable batching.

  2. Filtering (optional) -- Define event patterns to select which messages pass through.

  3. Transformation (optional) -- Apply data cleansing logic such as splitting, mapping, enriching, or dynamic routing via Function Compute.

  4. Sink -- Deliver processed messages to the destination SMQ queue.

Prerequisites

Before you begin, make sure you have:

Supported regions

SMQ is available as a sink in the following regions:

AreaRegions
ChinaChina (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Shenzhen), China (Chengdu), China (Hong Kong)
Asia PacificSingapore, Japan (Tokyo), Malaysia (Kuala Lumpur), Indonesia (Jakarta)
AmericasUS (Silicon Valley), US (Virginia)
EuropeGermany (Frankfurt)

Create a sink task

  1. Log on to the ApsaraMQ for RabbitMQ console.

  2. In the left-side navigation pane, choose Connector Ecosystem Integration > Tasks.

  3. In the top navigation bar, select a region, such as China (Hangzhou).

  4. On the Tasks page, click Create Task.

  5. Enter a Task Name and Description, then configure the pipeline stages described in the following sections.

  6. 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.

ParameterDescriptionExample
RegionThe region you selected in step 3. This value cannot be changed.China (Hangzhou)
RabbitMQ InstanceThe source ApsaraMQ for RabbitMQ instance that produces messages.amqp-cn-\*\*\*\*\*\*lpc00a
vhostThe vhost on the source instance.test
QueueThe queue on the source instance to read messages from.queue_test
MessagesMaximum 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.

ParameterDescriptionExample
Queue NameThe destination SMQ queue that receives messages from the source.test
Enable Base64 EncodingWhether to Base64-encode message data before delivery. Select Yes to encode or No to skip encoding.Yes
Message BodyThe 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:

ActionDescription
DetailsView the source, sink, and resource configurations on the Message Sink Details page.
EditModify the Resource Configuration and Rule Configuration in the Edit Message Sink panel.
Enable / DisableToggle the task on or off. Click Confirm in the dialog box.
DeletePermanently 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.