This topic describes how to use the event stream feature provided by EventBridge to route messages between Simple Message Queue (formerly MNS) (SMQ) queues.
Prerequisites
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.
SMQ queues are created. For more information, see Activate SMQ and authorize RAM users to access SMQ.
Background information
As a type of lightweight channel for processing end-to-end streaming data in real time, event streams allow you to filter and transform lightweight streaming data and synchronize data between data warehouses, between data processing programs, and between data analysis and data processing systems. You can use an event stream to route messages from a source SMQ queue to a destination SMQ queue without the need to define an event bus. For more information, see Overview.
Step 1: Create an event stream
EventBridge allows you to create an event stream to route messages only between SMQ queues that are deployed in the same region.
Log on to the EventBridge console.
In the top navigation bar, select the region where you want to create an event stream.
In the left-side navigation pane, click Event Streams.
On the Event Streams page, click Create Event Stream.
On the Create Event Stream page, configure the Task Name and Description parameters and follow the on-screen instructions to configure other parameters. Then, click Save. The following section describes the parameters:
Task Creation
In the Source step, set the Data Provider parameter to SMQ, follow the on-screen instructions to configure other parameters, and then click Next Step. The following table describes the parameters.
Parameter
Description
Example
Queue Name
The source SMQ queue that you created.
test-queue
Base64 Decoding
Specify whether to enable Base64 decoding. After you enable Base64 decoding, your data in SMQ is decoded in the Base64 format before the data is delivered to the destination service.
test
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 and Transformation steps, configure the event filtering method and event transformation rule. Then, click Next Step. For information about event transformation configurations, see Use Function Compute to perform message cleansing.
In the Sink step, set the Service Type parameter to SMQ and follow the on-screen instructions to configure other parameters. Then, click Save. The following table describes the parameters.
Parameter
Description
Example
Queue Name
The destination SMQ queue that you created.
test
Enable Base64 Encoding
Specify whether to enable Base64 encoding. If you disable this feature, the message that you receive contains garbled characters.
Yes
Message Body
The method that you want to use to transform events. For more information, see Event transformation.
Complete Event
Task Property
Specify the retry policy and dead-letter queue for the event stream. For more information, see Retry policies and dead-letter queues.
Go back to the Event Streams page, find the event stream that you created, and then click Enable in the Actions column.
The event stream requires 30 to 60 seconds to be enabled. You can view the progress in the Status column on the Event Streams page.
Step 2: Test the event stream
Log on to the SMQ console.
In the top navigation bar, select the region where the event stream that you created in Step 1: Create an event stream resides.
In the left-side navigation pane, choose Queue Model > Queues.
On the Queues page, find the source queue that you specified in Step 1: Create an event stream and click Details in the Actions column.
In the upper-right corner of the Queue Details page, click Send Messages.
On the Quick Experience page, configure the Message Content and Scheduled Period parameters and click Send Message.
After the message is sent, the ID of the sent message appears on this page.
After you send the message from the source queue, go back to the Queues page.
On the Queues page, find the destination queue that you specified in Step 1: Create an event stream and click Details in the Actions column.
In the upper-right corner of the Queue Details page, click Send Messages.
On the Quick Experience page, click Receive Message.
Check whether the ID and content of the returned message are the same as those of the sent message.