Simple Message Queue (formerly MNS) (SMQ) queues can serve as event sources for EventBridge. This topic describes how to create an SMQ-type custom event source in the EventBridge console.
Prerequisites
Before you begin, make sure that you have:
SMQ
EventBridge
Add an SMQ event source
Log on to the EventBridge console.
In the left-side navigation pane, click Event Buses.
In the top navigation bar, select a region.
On the Event Buses page, click the name of the event bus that you want to manage.
In the left-side navigation pane, click Event Sources.
Click Add Event Source.
In the Add Custom Event Source panel, configure the following parameters:
Parameter Description Name Enter a name for the event source. Description Enter a description for the event source. Event Provider Select SMQ from the drop-down list. Queue Name Select the SMQ queue to use as the event source. Click OK.
Sample event
When a message is sent to the SMQ queue, EventBridge generates a CloudEvent with the following structure:
{
"id": "bffb9722-9c48-407b-9895-b038f78f****",
"source": "acs:mns",
"specversion": "1.0",
"type": "mns:Queue:SendMessage",
"datacontenttype": "application/json; charset=utf-8",
"subject": "acs:mns:cn-hangzhou:123456789098****:queues/zeus",
"time": "2021-04-08T06:28:17.093Z",
"aliyunpublishtime": "2021-04-08T06:30:31.367Z",
"aliyuneventbusname": "mybus",
"data": {
"requestId": "606EA3074344430D4C81****",
"messageId": "C6DB60D1574661357FA227277445****",
"messageBody": "TEST"
}
}CloudEvents envelope fields
The top-level fields follow the CloudEvents specification:
| Field | Type | Description |
|---|---|---|
id | String | Unique event identifier. |
source | String | Event source identifier. For SMQ events, the value is acs:mns. |
specversion | String | CloudEvents specification version. The current value is 1.0. |
type | String | Event type. For queue messages, the value is mns:Queue:SendMessage. |
datacontenttype | String | Media type of the data field. |
subject | String | Resource path in the format acs:mns:<region-id>:<account-id>:queues/<queue-name>. |
time | String | Timestamp when the event occurred (ISO 8601). |
aliyunpublishtime | String | Timestamp when EventBridge published the event (ISO 8601). |
aliyuneventbusname | String | Name of the event bus that received the event. |
Data field parameters
The data object contains the original message details:
| Parameter | Type | Example | Description |
|---|---|---|---|
requestId | String | 606EA3074344430D4C81**** | Unique request ID for the send operation. |
messageId | String | C6DB60D1574661357FA227277445**** | Unique message ID assigned by the queue. |
messageBody | String | TEST | Body of the message sent to the queue. |