All Products
Search
Document Center

EventBridge:Use event streams to route messages between SMQ queues

Last Updated:Nov 13, 2024

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

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

Note

EventBridge allows you to create an event stream to route messages only between SMQ queues that are deployed in the same region.

  1. Log on to the EventBridge console.

  2. In the top navigation bar, select the region where you want to create an event stream.

  3. In the left-side navigation pane, click Event Streams.

  4. On the Event Streams page, click Create Event Stream.

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

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

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

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

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

  1. Log on to the SMQ console.

  2. In the top navigation bar, select the region where the event stream that you created in Step 1: Create an event stream resides.

  3. In the left-side navigation pane, choose Queue Model > Queues.

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

  5. In the upper-right corner of the Queue Details page, click Send Messages.

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

  7. After you send the message from the source queue, go back to the Queues page.

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

  9. In the upper-right corner of the Queue Details page, click Send Messages.

  10. On the Quick Experience page, click Receive Message.

  11. Check whether the ID and content of the returned message are the same as those of the sent message.