Synchronizing data to Function Compute
Create a message outflow task to route messages from an ApsaraMQ for RabbitMQ queue to a Function Compute function for event-driven processing.
How it works
When messages arrive in a RabbitMQ queue, the connector batches them and invokes your Function Compute function. A function invocation is triggered when either condition is met:
The number of accumulated messages reaches the configured batch size.
The configured time interval elapses.
Prerequisites
Before you begin, make sure that you have:
An ApsaraMQ for RabbitMQ instance in the Running state. See Creating resources
Function Compute activated. See Activate Function Compute
EventBridge activated with required permissions granted to a Resource Access Management (RAM) user. See Activate EventBridge and grant permissions
Create a message outflow 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.
On the Create Task page, configure the Task Name and Description parameters.
Complete the following configuration steps and click Save.
Step 1: Configure the source
In the Source step, set Data Provider to ApsaraMQ for RabbitMQ, configure the following parameters, and then click Next.
| Parameter | Description | Example |
|---|---|---|
| Region | The region selected when the message sink task was created. This value cannot be changed. | China (Hangzhou) |
| RabbitMQ Instance | The source instance that produces messages. | amqp-cn-\*\*\*\*\*\*lpc00a |
| vhost | The vhost on the source instance. | test |
| Queue | The queue on the source instance to consume messages from. | queue_test |
| Messages | The maximum number of messages per batch. A function invocation is triggered only after this number of messages accumulates. Valid values: 1 to 10000. | 100 |
| Interval (Unit: Seconds) | The interval at which the function is called. The system aggregates messages and sends them to Function Compute at this interval. Valid values: 0 to 15. Set to 0 to deliver messages immediately without waiting. | 3 |
Step 2: Configure filtering
In the Filtering step, set the Pattern Content filter to control which messages are forwarded to Function Compute. See Event patterns.
Step 3: Configure transformation
In the Transformation step, configure data cleansing to apply operations such as segmentation, mapping, enrichment, and dynamic routing before messages reach your function. See Use Function Compute for message data cleansing.
Step 4: Configure the sink
In the Sink step, set Service Type to Function Compute and configure the following parameters.
| Parameter | Description | Example |
|---|---|---|
| Service | The Function Compute service. | test |
| Function | The Function Compute function to invoke. | test |
| Version and Alias | The service version or alias to use. | Specified Version |
| Version | The function version. Select the latest version unless a specific version is required. | LATEST |
| Invocation Mode | The invocation mode. Valid values: Synchronous and Asynchronous. | Asynchronous |
| Event | The event transformation method. See Event transformation. | Complete Data |
Step 5: Configure task properties
Configure the retry policy for failed events and the error handling method. See Retries and dead-letter queues.
Manage tasks
On the Tasks page, find the target task and use the Actions column to perform the following operations:
| Operation | Description |
|---|---|
| Details | View the source, sink, and resource configurations of the task on the Message Sink Details page. |
| Edit | Modify the Resource Configuration and Rule Configuration in the Edit Message Sink panel. |
| Enable / Disable | Enable or disable the task. Click Confirm in the Note dialog box. |
| Delete | Delete the task. Click Confirm in the Note dialog box. |