All Products
Search
Document Center

EventBridge:Create a custom event source of the ApsaraMQ for RocketMQ type

Last Updated:Mar 15, 2024

EventBridge allows you to connect to ApsaraMQ for RocketMQ to analyze events, view event traces, and forward data. This topic describes how to create a custom event source of the ApsaraMQ for RocketMQ type in the EventBridge console.

Prerequisites

Procedure

  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, click Event Buses.
  3. In the top navigation bar, select a region.
  4. On the Event Buses page, click the name of the event bus that you want to manage.

  5. In the left-side navigation pane, click Event Sources.

  6. On the page that appears, click Add Event Source.Event Source

  7. In the Add Custom Event Source panel, configure the Name and Description parameters. Then, select Message Queue for Apache RocketMQ from the Event Provider drop-down list, follow the on-screen instructions to configure other parameters, and then click OK. The following items describe the parameters:

    • Region: Select the region where the ApsaraMQ for RocketMQ instance that you created resides.

    • Version: Select the version of the ApsaraMQ for RocketMQ instance. Valid values: RocketMQ 4.x and RocketMQ 5.x.

    • Instance: Select the ApsaraMQ for RocketMQ instance that you created.

    • Topic: Select the topic that you created on the ApsaraMQ for RocketMQ instance.

    • (Optional) Tag: Enter a tag to filter messages.

    • Group ID: Select the ID of the consumer group that you created on the ApsaraMQ for RocketMQ instance.

      Note

      A group corresponds to a type of business message. Do not specify a consumer group that is used in existing business. Make sure that you use different group IDs for different event sources.

    • Consumer Offset: Select an offset from which messages are consumed. Default value: Latest Offset.

Sample event

{
    "id":"94ebc15f-f0db-4bbe-acce-56fb72fb****",
    "source":"acs:mq",
    "specversion":"1.0",
    "type":"mq:Topic:SendMessage",
    "datacontenttype":"application/json; charset=utf-8",
    "subject":"acs:mq:cn-hangzhou:123456789098****:MQ_INST_123456789098****_BXhFHryi%TopicName",
    "time":"2021-04-08T06:01:20.766Z",
    "aliyunpublishtime":"2021-04-08T06:01:20.725Z",
    "aliyuneventbusname":"BusName",
    "data":{
        "topic":"TopicName",
        "systemProperties":{
            "MIN_OFFSET":"0",
            "TRACE_ON":"true",
            "MAX_OFFSET":"8",
            "MSG_REGION":"cn-hangzhou",
            "KEYS":"systemProperties.KEYS",
            "CONSUME_START_TIME":1628577790396,
            "UNIQ_KEY":"AC14C305069E1B28CDFA3181CDA2****",
            "TAGS":"systemProperties.TAGS",
            "INSTANCE_ID":"MQ_INST_123456789098****_BXhFHryi"
        },
        "userProperties":{
        },
        "body":"TEST"
    }
}

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

The following table describes the parameters contained in data.

Parameter

Type

Example

Description

topic

String

TopicName

The topic name.

systemProperties

Map

The system properties.

MIN_OFFSET

Int

0

The earliest offset.

TRACE_ON

Boolean

true

Indicates whether a message trace exists. Valid values:

  • true

  • false

MAX_OFFSET

Int

8

The latest offset.

MSG_REGION

String

cn-hangzhou

The region from which the message is sent.

KEYS

String

systemProperties.KEYS

The keys that are used to filter the message.

CONSUME_START_TIME

Long

1628577790396

The start time of message consumption. Unit: milliseconds.

UNIQ_KEY

String

AC14C305069E1B28CDFA3181CDA2****

The unique key of the message.

TAGS

String

systemProperties.TAGS

The tags that are used to filter the message.

INSTANCE_ID

String

MQ_INST_123456789098****_BXhFHryi

The ID of the ApsaraMQ for RocketMQ instance.

userProperties

Map

None

The user properties.

body

String

TEST

The message body.