This topic describes how to add Message Service (MNS) as an event stream source in the EventBridge console.
Prerequisites
EventBridge is activated and the required permissions are granted.
A Message Service (MNS) queue is created. For more information, see Activate Message Service (MNS) and grant permissions.
Procedure
Log on to the EventBridge console. In the left-side navigation pane, click Event Streams.
In the top navigation bar, select a region and click Create Event Stream.
On the Create Event Stream page, enter a Task name and Description, configure the following parameters, and then click Save.
Create task
In the Source step, set Data Provider to Simple Message Queue (formerly MNS), configure the following parameters, and then click Next Step.
Parameter
Description
Example
Queue Name
Select the Simple Message Queue (formerly MNS) queue that you want to use as the event source.
test-queue
Base64 Decoding
Select this check box to allow EventBridge to decode data from Simple Message Queue (formerly MNS) before delivery.
test
Batch Push
A batch push is triggered when the value of Messages or Interval (Unit: Seconds) is reached, whichever comes first.
For example, if you set Batch Size to 100 and Batch Window to 15s, a batch is pushed when 100 messages are collected, even if only 10s have passed.
Enabled
Messages
The maximum number of messages in a batch. EventBridge sends a batch when the number of messages reaches this value. Valid values: 1 to 10,000.
100
Interval (Unit: Seconds)
The maximum period of time to wait before a batch is sent. EventBridge sends a batch when the specified period of time ends. Valid values: 0 to 15. Unit: seconds. A value of 0 specifies no wait time.
3
In the Filtering, Transformation, and Sink steps, configure event filtering rules, transformation rules, and an event sink. For more information about event transformation, see Use Function Compute to cleanse message data.
Task properties
Configure a retry policy and a dead-letter queue for the event stream. For more information, see Retries and dead-letter queues.
On the Event Streams page, find the event stream that you created and click Enable in the Actions column.
After you enable the event stream, the stream starts after a 30- to 60-second delay. You can view the startup progress in the Status column on the Event Streams page.
Sample event
{
"specversion":"1.0",
"id":"bffb9722-9c48-407b-9895-b038f78f****",
"source":"acs:mns",
"type":"mns:Queue:SendMessage",
"subject":"acs:mns:cn-hangzhou:123456789098****:queues/zeus",
"datacontenttype":"application/json; charset=utf-8",
"time":"2021-04-08T06:28:17.093Z",
"aliyunpublishtime":"2021-04-08T06:30:31.367Z",
"aliyuneventbusname":"mybus",
"data":{
"requestId":"606EA3074344430D4C81****",
"messageId":"C6DB60D1574661357FA227277445****",
"messageBody":"TEST"
}
}For more information about the parameters that are defined in the CloudEvents specification, see Event structure.
The following table describes the parameters in the data field.
Parameter | Type | Example | Description |
requestId | String | 606EA3074344430D4C81**** | The request ID. This parameter is globally unique. |
messageId | String | C6DB60D1574661357FA227277445**** | The message ID. This parameter is globally unique. |
messageBody | String | TEST | The message body. |