Message Queue for MQTT

更新时间:
复制 MD 格式

This topic describes how to configure Message Queue for MQTT as an event source for an event stream in the EventBridge console.

Prerequisites

Procedure

  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. In the Create Event Stream panel, enter a Task name and Description, configure the following parameters, and then click Save.

    • Task Creation

      1. In the Source step, set Data Provider to Message Queue for MQTT, configure the following parameters, and then click Next Step.

        Parameter

        Description

        Example

        MQTT Instance

        Select an MQTT instance.

        test-instance

        MQTT Topic

        Select a topic from the Message Queue for MQTT instance.

        test-topic

        Batch Push

        The batch push feature aggregates multiple events. A push is triggered when either the number of messages reaches the configured Messages threshold or the specified Interval (Unit: Seconds) elapses.

        For example, if you set Messages to 100 and the interval to 15s, a push is triggered when 100 messages are collected, even if this occurs before the 15-second interval is over.

        Enabled

        Messages

        The maximum number of messages to send in a batch. A batch is sent when the number of collected messages reaches this value. Valid values: 1 to 10,000.

        100

        Interval (Unit: Seconds)

        The maximum time, in seconds, to wait before sending a batch. A batch is sent when this interval elapses. Valid values: [0,15]. Unit: seconds. A value of 0 means no wait time and messages are delivered immediately.

        3

      2. In the Filtering, Transformation, and Sink steps, configure event filtering and transformation, and specify the event sink. For more information about how to configure event transformation, see Use Function Compute to cleanse message data.

    • Task Properties

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

  4. On the Event Streams page, find your event stream and click Enable in the Actions column.

    After you enable the event stream, the configuration takes 30 to 60 seconds to take effect. You can view the progress in the Status column on the Event Streams page.

Sample event

{
    "specversion":"1.0",
    "id":"AC1EC0C950650816F27D46F7D7CA****",
    "source":"acs:mqtt",
    "type":"mqtt:Topic:SendMessage",
    "subject":"acs:mq:cn-hangzhou:143998900779****:topic/mqtt-cn-2r42qam****/housekee****",
    "datacontenttype":"application/json; charset\u003dutf-8",
    "time":"2022-06-22T03:53:47.959Z",
    "aliyunaccountid":"143998900779****",
    "data":{
        "props":{
            "firstTopic":"housekee****",
            "secondTopic":"/testMq4****",
            "clientId":"GID_****"
        },
        "body":"TEST"
    }
}

For more information about the parameters defined in the CloudEvents specification, see Event overview.

The parameters in the data field are described in the following table.

Parameter

Type

Example

Description

props

Map

The message properties.

firstTopic

String

housekee****

The parent topic for sending and receiving messages.

secondTopic

String

/testMq4****

The subtopic.

clientId

String

GID_****

The client ID.

body

String

TEST

The message body.