You can use the global message routing feature provided by ApsaraMQ for RabbitMQ in the same manner as you use the Shovel plug-in of open source RabbitMQ. You can use this feature to forward messages from a queue to another queue or an exchange. The message source and message destination can belong to different instances or vhosts in the same region or different regions.
Usage notes
Extra fees are incurred. The total fees that you are charged for the global message routing feature are calculated by using the following formula: Total fees = Fees incurred by ApsaraMQ for RabbitMQ + Forwarding fees incurred by EventBridge + Traffic fees incurred by Cloud Enterprise Network (CEN). Traffic fees are incurred only when you forward messages across regions. For information about the billing of ApsaraMQ for RabbitMQ, see Billing of subscription instances. For information about the billing of EventBridge, see Billing. For information about the billing of CEN, see Billing rules.
Relay message routing is not supported. If you want to forward messages from Instance A to Instance C, you must create a route from Instance A to Instance C. You cannot forward messages from Instance A to Instance B and then to Instance C.
Latency may occur during synchronization. During message synchronization, the number of synchronized messages and limited network bandwidth can cause latency.
Prerequisites
ApsaraMQ for RabbitMQ
The source instance, vhost, exchange, and queue are created and available. The destination instance, vhost, exchange, and queue are created and available. For more information, see the following topics:
EventBridge
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 global message routing task
Log on to the ApsaraMQ for RabbitMQ console. In the left-side navigation pane, click Global Message Routing.
On the Global Message Routing page, click Create Task.
(Optional) In the Alibaba Cloud Service Authorization - Message Queue RabbitMQ dialog box, read the message and click OK.
The first time you create a global message routing task, the following service-linked roles are automatically created: AliyunServiceRoleForEventBridgeSourceRabbitMQ and AliyunServiceRoleForEventBridgeSendToRabbitMQ. For more information, see Service-linked roles.
NoteEventBridge assumes the AliyunServiceRoleForEventBridgeSourceRabbitMQ role to receive messages sent by the source instance.
EventBridge assumes the AliyunServiceRoleForEventBridgeSendToRabbitMQ role to forward messages to the destination instance.
On the Create Message Routing Task page, configure the information about the source instance and destination instance of the message routing task.
In the Basic Information step, specify the task name and description and click Next.
In the Source and Destination step, configure the information about the source instance and destination instance of the message routing task and click Next.
Parameter
Description
Example
Source
Service Type
The type of the instance from which you want to route messages. This parameter is automatically set to Message Queue for RabbitMQ.
Message Queue for RabbitMQ
Region
The region where the source instance is deployed.
China (Shenzhen)
Instance
The ID of the source instance.
amqp-cn-i7m2a8bq****
vhost
The vhost that is created on the source instance.
test-001
Queue
The queue that is created on the source instance.
test-001-q
Destination
Service Type
The type of the instance to which you want to route messages. This parameter is automatically set to Message Queue for RabbitMQ.
Message Queue for RabbitMQ
Region
The region where the destination instance is deployed.
China (Shenzhen)
Instance
The ID of the destination instance.
amqp-cn-7pp2a85q****
vhost
The vhost that is created on the destination instance.
test-routing
Destination Type
The type of the resource to which you want to forward messages. Valid values:
Queue: Messages are forwarded to one or more queues on the destination instance.
Exchange: Messages are forwarded to one or more exchanges on the destination instance.
NoteIf you set the Destination Type parameter to Exchange, make sure that the destination exchange is bound to a queue. Otherwise, messages that are forwarded to the destination exchange are lost because no queue can be used to store the messages.
test-routing-ex
Routing Key
The routing key that is used for message routing. This parameter is available only if you set the Destination Type parameter to Exchange. Valid values:
Not Set: The existing routing key is used to forward messages to the destination exchange.
Set: The configured routing key is used to forward messages to the destination exchange.
test
In the Create and Start step, confirm the configurations of the message routing task and click Create and Start.
After the message routing task is created, you can view the task on the Global Message Routing page. The status of the message routing task is displayed as Running in the Status column.
References
For information about the Shovel plug-in of open source RabbitMQ, see Shovel Plugin.