ApsaraMQ for MQTT

Updated at:

Add ApsaraMQ for MQTT as an event source for an event stream in the 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 the Task Name and Description.

  4. In the Source configuration wizard of the Task Creation phase, set Data Provider to ApsaraMQ for MQTT, configure the following parameters, and then click Next.

    ParameterDescriptionExample
    MQTT InstanceSelect an MQTT instance.test-instance
    MQTT TopicSelect a topic in the MQTT instance.test-topic
    Batch PushBatch push aggregates multiple events into batches. A batch push is triggered as soon as either the Messages condition or the Interval (Unit: Seconds) condition is met. For example, if you set the number of messages to 100 and the interval to 15 seconds, and 100 messages are collected within 10 seconds, the push is triggered immediately instead of waiting for the remaining 15 seconds.Enabled
    MessagesThe maximum number of messages sent in a batch. A batch is sent only after the number of accumulated messages reaches this value. Valid values: 1 to 10,000.100
    Interval (Unit: Seconds)The interval at which the system aggregates messages and pushes them to the event target. Valid values: 0 to 15. Unit: seconds. A value of 0 specifies no wait time, and messages are delivered immediately.3
  5. In the Filtering, Transformation, and Sink configuration wizards, configure the event filtering rules, event transformation rules, and event target. For more information about event transformation, see Use Function Compute to cleanse message data.

  6. In the Task Properties phase, configure the retry policy and the dead-letter queue of the event stream. For more information, see Retry policies and dead-letter queues.

  7. Click Save.

  8. Return to the Event Streams page, find the event stream that you created, and click Enable in the Actions column on the right.

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

Sample event

The following example shows a sample event from ApsaraMQ for MQTT:

{
    "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 following table describes the parameters in the data field.

ParameterTypeExampleDescription
propsMap{"firstTopic":"housekee****","secondTopic":"/testMq4****","clientId":"GID_****"}The message properties.
props.firstTopicStringhousekee****The parent topic used to send and receive messages.
props.secondTopicString/testMq4****The subtopic.
props.clientIdStringGID_****The client ID.
bodyStringTESTThe message content.