CreateEventSource

更新时间:
复制 MD 格式

Creates a custom event source.

URL

/openapi/createEventSource

Usage notes

You can specify only one of the SourceMNSParameters, SourceRocketMQParameters, SourceRabbitMQParameters, SourceHttpEventParameters, SourceSLSParameters parameters for an event source.

Request parameters

ParameterTypeRequiredExampleDescription
EventSourceNameStringYesmyrabbitmq.sourceThe name of the event source. For more information, see Limits.
DescriptionStringYesEvent source of the Message Queue for RabbitMQ typeThe description of the event source.
SourceMNSParametersObjectNoSpecifies that the event provider is Simple Message Queue (formerly MNS). For more information, see Request parameter SourceMNSParameters.
SourceRocketMQParametersObjectNoSpecifies that the event provider is ApsaraMQ for RocketMQ. For more information, see Request parameter SourceRocketMQParameters.
SourceRabbitMQParametersObjectNoSpecifies that the event provider is ApsaraMQ for RabbitMQ. For more information, see Request parameter SourceRabbitMQParameters.
SourceHttpEventParametersObjectNoSpecifies that the event provider is HTTP or HTTPS. For more information, see Request parameter SourceHttpEventParameters.
SourceSLSParametersObjectNoSpecifies that the event provider is Log Service. For more information, see Request parameter SourceSLSParameters.
EventBusNameStringYesmy-event-busThe name of the event bus with which the event source is to be associated. For more information, see Limits.

Request parameter SourceMNSParameters

If you specify the SourceMNSParameters parameter, you can configure the parameters described in the following table.

ParameterTypeRequiredExampleDescription
RegionIdStringYescn-zhangjiakouThe ID of the region where the Simple Message Queue (formerly MNS) queue resides.
QueueNameStringYesMyQueueThe name of the queue in the Simple Message Queue (formerly MNS) instance.
IsBase64DecodeStringYestrueSpecifies whether to enable Base64 decoding. Default value: true.

Request parameter SourceRocketMQParameters

If you specify the SourceRocketMQParameters parameter, you can configure the parameters described in the following table.

ParameterTypeRequiredExampleDescription
RegionIdStringYescn-zhangjiakouThe ID of the region where the ApsaraMQ for RocketMQ instance resides.
InstanceIdStringYesMQ_INST_164901546557****_BAAN****The ID of the ApsaraMQ for RocketMQ instance. For more information, see Limits.
TopicStringYesmytopicThe name of the topic in the ApsaraMQ for RocketMQ instance. For more information, see Limits.
TagStringNotestThe tags that are used to filter messages.
OffsetStringNoCONSUME_FROM_TIMESTAMPThe consumer offset of messages. Valid values:
  • CONSUME_FROM_LAST_OFFSET: Consumption starts from the latest offset.
  • CONSUME_FROM_FIRST_OFFSET: Consumption starts from the earliest offset.
  • CONSUME_FROM_TIMESTAMP: Consumption starts from the offset at the specified point in time.

Default value: CONSUME_FROM_LAST_OFFSET.

TimestampLongNo1636597951964The timestamp of the offset from which consumption starts. Unit: milliseconds. This parameter is valid only if you set the Offset parameter to CONSUME_FROM_TIMESTAMP.
GroupIDStringYesGID_group1The ID of the group in the ApsaraMQ for RocketMQ instance.

Request parameter SourceRabbitMQParameters

If you specify the SourceRabbitMQParameters parameter, you can configure the parameters described in the following table.

ParameterTypeRequiredExampleDescription
RegionIdStringYescn-zhangjiakouThe ID of the region where the ApsaraMQ for RabbitMQ instance resides.
InstanceIdStringYesamqp-cn-nif22u74****The ID of the ApsaraMQ for RabbitMQ instance. For more information, see Limits.
VirtualHostNameStringYeseb-connectThe name of the vhost in the ApsaraMQ for RabbitMQ instance. For more information, see Limits.
QueueNameStringYesdemoThe name of the queue in the ApsaraMQ for RabbitMQ instance. For more information, see Limits.

Request parameter SourceHttpEventParameters

If you specify the SourceHttpEventParameters parameter, you can set the parameters described in the following table.

ParameterTypeRequiredExampleDescription
TypeStringYesHTTPSThe protocol type supported by the generated webhook URL. Valid values:
  • HTTP
  • HTTPS
  • HTTP&HTTPS
MethodListYesGETThe HTTP request method supported by the generated webhook URL. You can select multiple values. Valid values:
  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
  • HEAD
  • OPTIONS
  • TRACE
  • CONNECT
SecurityConfigStringYesipThe type of security settings. Valid values:
  • none: no security settings.
  • ip: CIDR blocks.
  • referer: security domain names.
IpListNo10.0.0.0/8The CIDR blocks used for security settings. This parameter is required only if you set the SecurityConfig parameter to ip. You can enter CIDR blocks or IP addresses. Separate multiple CIDR blocks or IP addresses with commas (,).
RefererListNoaliyundoc.comThe security domain names. This parameter is required only when you set the SecurityConfig parameter to referer. You can enter domain names.

Request parameter SourceSLSParameters

If you specify the SourceSLSParameters parameter, you can configure the parameters described in the following table.

ParameterTypeRequiredExampleDescription
ProjectStringYestest-projectThe Log Service project.
LogStoreStringYestest-logstoreThe Log Service Logstore.
ConsumePositionStringNoendThe starting consumer offset. The value begin indicates the earliest offset, and the value end indicates the latest offset. You can also specify a time in seconds to start consumption.
RoleNameStringYestestRoleThe name of the role. If you want to authorize EventBridge to use this role to read the logs in Log Service, you must select Alibaba Cloud Service for the Selected Trusted Entity parameter, and select EventBridge for the Select Trusted Service parameter when you create the role in the RAM console. For information about the permission policy of this role, see Create a custom event source of the Simple Log Service type.

Response parameters

ParameterTypeExampleDescription
EventSourceARNStringacs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/mymns.sourceThe Alibaba Cloud Resource Name (ARN) of the event source.

Example 1: Custom event source of the MNS type

Sample request

POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26

{
    "EventSourceName":"mymns.source",
    "Description":"Event source of the MNS type",
    "SourceMNSParameters":{
        "RegionId":"cn-zhangjiakou",
        "QueueName":"MyQueue",
        "IsBase64Decode":true
    },
     "EventBusName":"my-event-bus"
}

Sample response

HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT

{
    "code":"200",
    "data":{
        "RequestId":"244BED53-719A-15D7-B7F9-1C404273****",
        "Data":{
            "EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/mymns.source"
        },
        "Code":"Success",
        "Success":true
    },
    "httpStatusCode":"200",
    "requestId":"244BED53-719A-15D7-B7F9-1C404273****",
    "successResponse":true
}

Example 2: Custom event source of the Message Queue for Apache RocketMQ type

Sample request

POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26

{
    "EventSourceName":"myRocketMQ.source",
    "Description":"Event source of the Message Queue for Apache RocketMQ type",
    "SourceRocketMQParameters":{
        "InstanceId":"MQ_INST_164901546557****_BAAN****",
        "GroupID":"GID_group1",
        "Topic":"mytopic",
        "Offset":"CONSUME_FROM_TIMESTAMP",
        "Tag":"test",
        "RegionId":"cn-hangzhou",
        "Timestamp":1636597951964
    },
    "EventBusName":"my-event-bus"
}

Sample response

HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT

{
    "code":"200",
    "data":{
        "RequestId":"244BED53-719A-15D7-B7F9-1C404273****",
        "Data":{
            "EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/myRocketMQ.source"
        },
        "Code":"Success",
        "Success":true
    },
    "httpStatusCode":"200",
    "requestId":"244BED53-719A-15D7-B7F9-1C404273****",
    "successResponse":true
}

Example 3: Custom event source of the Message Queue for RabbitMQ type

Sample request

POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26

{
    "EventSourceName":"myRabbitMQ.source",
    "Description":"Event source of the Message Queue for RabbitMQ type",
    "SourceRabbitMQParameters":{
        "RegionId":"cn-hangzhou",
        "InstanceId":"amqp-cn-nif22u74****",
        "VirtualHostName":"eb-connect",
        "QueueName":"demo"
    },
    "EventBusName":"my-event-bus"
}

Sample response

HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT

{
    "code":"200",
    "data":{
        "RequestId":"244BED53-719A-15D7-B7F9-1C404273****",
        "Data":{
            "EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/myRabbitMQ.source"
        },
        "Code":"Success",
        "Success":true
    },
    "httpStatusCode":"200",
    "requestId":"244BED53-719A-15D7-B7F9-1C404273****",
    "successResponse":true
}

Example 4: Custom event source of the HTTP/HTTPS type

Sample request

POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT****azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26

{
    "EventSourceName":"myhttp.source",
    "Description":"Event source of the HTTP or HTTPS type",
    "SourceHttpEventParameters":{
        "Type":"HTTPS",
        "Method":["GET","POST"],
        "SecurityConfig":"ip",
        "Ip":["10.0.0.0/8", "192.168.XX.XX"]
    },
     "EventBusName":"my-event-bus"
}

Sample response

HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT

{
    "code":"200",
    "data":{
        "RequestId":"325BED98-734A-15D7-P7F1-7B409088****",
        "Data":{
            "EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/myhttp.source"
        },
        "Code":"Success",
        "Success":true
    },
    "httpStatusCode":"200",
    "requestId":"325BED98-734A-15D7-P7F1-7B409088****",
    "successResponse":true
}

Example 5: Custom event source of the Log Service type

Sample request

POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26

{
  "EventSourceName":"mySLS.source",
  "Description":"Event source of the Log Service type",
  "SourceSLSParameters":{
    "RegionId":"cn-hangzhou",
    "Project":"test-project",
    "LogStore":"test-logstore",
    "ConsumePosition":"end",
      "RoleName":"testRole"
  },
  "EventBusName":"my-event-bus"
}

Sample response

HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT

{
    "code":"200",
    "data":{
        "RequestId":"325BED98-734A-15D7-P7F1-7B409088****",
        "Data":{
            "EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/mySLS.source"
        },
        "Code":"Success",
        "Success":true
    },
    "httpStatusCode":"200",
    "requestId":"325BED98-734A-15D7-P7F1-7B409088****",
    "successResponse":true
}