All Products
Search
Document Center

EventBridge:Route events to SMQ

Last Updated:Oct 22, 2024

This topic describes how to configure Simple Message Queue (formerly MNS) (SMQ) as the sink of an event stream in the EventBridge console.

Prerequisites

Create an event stream

  1. Log on to the EventBridge console. In the left-side navigation pane, click Event Streams.

  2. In the top navigation bar, select a region and click Create Event Stream.

  3. 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, Filtering, and Transformation steps, specify the event source, filtering method, and transformation rule. Then, click Next Step. For information about the configurations of event transformation, see Use Function Compute to perform message cleansing.

      2. In the Sink step, set the Service Type parameter to SMQ and follow the on-screen instructions to configure other parameters. The following table describes the parameters.

        Parameter

        Description

        Example

        Queue Name

        The 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

      Configure the retry policy and dead-letter queue for the event stream. For more information, see Retry policies and dead-letter queues.

  4. Go back to the Event Streams page and find the event stream that you created. Then, click Enable in the Actions column.

    Enabling an event stream requires 30 to 60 seconds to complete. You can view the progress in the Status column of the event stream on the Event Streams page.

Verify the result

You can check whether events are received in the SMQ console.

  1. Log on to the SMQ console. In the left-side navigation pane, click Queues.

  2. In the top navigation bar, select a region.

  3. On the Queues page, find the queue to which you routed the events and choose More > Send Messages in the Actions column.

  4. In the Receive Message section of the Quick Experience page, click Receive Message.

    The following sample code provides an example of received events:

    {
        "data":{
           "props":{
                "firstTopic":"topci12****",
                "secondTopic":"",
                "clientId":"GID_MQTT_CONSOLE@@@lmqhb1share01vpc165759566****"
           },
           "body":"Hello World"
        },
        "id":"AC11C08E76C67E7740853B0F604D****",
        "source":"acs:mqtt",
        "specversion":"1.0",
        "type":"mqtt:Topic:SendMessage",
        "datacontenttype":"application/json; charset\u003dutf-8",
        "time":"2022-07-12T03:14:23.447Z",
        "subject":"acs:mq:cn-qingdao:182572506381****:topic/mqtt-cn-2r42rdr****/topci12****",
        "aliyunaccountid":"182572506381****"
    }