CreateEventStreaming

更新时间:
复制 MD 格式

Creates an event stream.

URL

/eventstreaming/createEventStreaming

Usage notes

  • In an event stream, only one of the SourceMNSParameters, SourceRocketMQParameters, SourceRabbitMQParameters, and SourceSLSParameters parameters can be returned.
  • In an event stream, you can specify only one of the SinkMNSParameters, SinkRocketMQParameters, SinkRabbitMQParameters, and SinkSLSParameters parameters.

Request parameters

ParameterTypeRequiredExampleDescription
EventStreamingNameStringYesmyeventstreamingThe name of the event stream.
DescriptionStringYesrocketmq2mnsThe description of the event stream.
SourceObjectYesSourceRocketMQParametersThe event provider.
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.
SourceSLSParametersObjectNoSpecifies that the event provider is Log Service. For more information, see Request parameter SinkSLSParameters.
FilterPatternStringNoNone.The rule that is used to filter events. If you leave this parameter empty, all events are matched.
SinkObjectYesSinkMNSParametersThe event target.
SinkMNSParametersObjectNoSpecifies that the event target is Simple Message Queue (formerly MNS). For more information, see Request parameter SinkMNSParameters.
SinkRocketMQParametersObjectNoSpecifies that the event target is ApsaraMQ for RocketMQ. For more information, see Request parameter SinkRocketMQParameters.
SinkRabbitMQParametersObjectNoSpecifies that the event target is ApsaraMQ for RabbitMQ. For more information, see Request parameter SinkRabbitMQParameters.
SinkSLSParametersObjectNoSpecifies that the event target is Log Service. For more information, see Request parameter SinkSLSParameters.
RunOptionsObjectNoThe runtime environment.
RetryStrategyStringYesBACKOFF_RETRYThe retry policy to be used when an event fails to be pushed. Valid values:
  • BACKOFF_RETRY: backoff retry. The request can be retried up to three times. The interval between two consecutive retries is a random value between 10 and 20 seconds.
  • EXPONENTIAL_DECAY_RETRY: exponential decay retry. The request can be retried up to 176 times. The interval between two consecutive retries exponentially increases to 512 seconds, and the total retry time is one day. The specific retry intervals are 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, ..., and 512 seconds, including a maximum of one hundred and sixty-seven 512 seconds in total.

Default value: BACKOFF_RETRY.

ErrorsToleranceStringYesALLThe fault tolerance policy. The policy specifies whether to ignore an error when the error occurs. Valid values:
  • ALL: ignores the error.
  • NONE: does not ignore the error.

Default value: ALL.

DeadLetterQueueObjectYesSpecifies whether to enable dead-letter queues. By default, dead-letter queues are disabled. Messages that fail to be pushed after allowed retries as specified by the retry policy are discarded.
ArnStringNoacs:mq:cn-chengdu:164901546557****:/instances/MQ_INST_164901546557****_BXxk0KXx/topic/MytopicThe Alibaba Cloud Resource Name (ARN) of the topic in the ApsaraMQ for RabbitMQ instance.

Request parameter SourceMNSParameters

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

ParameterTypeRequiredExampleDescription
QueueNameStringYesdemoThe name of the queue in the Simple Message Queue (formerly MNS) instance.
IsBase64DecodeStringYestrueSpecifies whether to enable Base64 encoding. Default value: true.

Request parameter SourceRocketMQParameters

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

ParameterTypeRequiredExampleDescription
RegionIdStringYescn-hangzhouThe 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. This parameter is valid only when 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
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 SourceSLSParameters

If you specify the SourceMNSParameters 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.

Request parameter SinkMNSParameters

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

ParameterTypeRequiredExampleDescription
QueueNameTargetParameterYesThe name of the queue that you specify when the event target is Simple Message Queue (formerly MNS).
ValueStringYesMyQueueThe name of the queue in the Simple Message Queue (formerly MNS) instance.
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.
BodyTargetParameterNoThe content of the message.
FormStringNoTEMPLATEThe transformation method.
ValueStringYes
{
  "key": "value"
}
The value before the transformation.
TemplateStringNoThe value of ${key} is ${value}!The template based on which events are to be transformed.
IsBase64EncodeTargetParameterYesSpecifies whether to enable Base64 encoding.
ValueStringYestrueEnables Base64 encoding.
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.

Request parameter SinkRocketMQParameters

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

ParameterTypeRequiredExampleDescription
InstanceIdTargetParameterYesThe ID of the instance that you specify when the event target is ApsaraMQ for RocketMQ.
ValueStringYesMQ_INST_164901546557****_BAAN****The ID of the ApsaraMQ for RocketMQ instance. For more information, see Limits.
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.
TopicTargetParameterYesThe topic in the ApsaraMQ for RocketMQ instance.
ValueStringYesMytopicThe name of the topic in the ApsaraMQ for RocketMQ instance. For more information, see Limits.
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.
BodyTargetParameterYesThe content of the message.
FormStringNoNoTEMPLATE
ValueStringYes
{
  "key": "value"
}
The value before the transformation.
TemplateStringYesThe value of ${key} is ${value}!The template based on which events are to be transformed.
PropertiesTargetParameterYesThe properties that are used to filter messages.
ValueStringYes
{
  "key": "value"
}
The value before the transformation.
FormStringNoTEMPLATEThe transformation method.
TemplateStringYesThe value of ${key} is ${value}!The template based on which events are to be transformed.
KeysTargetParameterYesThe properties that are used to filter messages.
ValueStringYes
{
  "key": "value"
}
The value before the transformation.
FormStringNoTEMPLATEThe transformation method.
TemplateStringYesThe value of ${key} is ${value}!The template based on which events are to be transformed.
TagsTargetParameterYesThe properties that are used to filter messages.
ValueStringYes
{
  "key": "value"
}
The value before the transformation.
FormStringNoTEMPLATEThe transformation method.
TemplateStringYesThe value of ${key} is ${value}!The template based on which events are to be transformed.

Request parameter SinkRabbitMQParameters

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

ParameterTypeRequiredExampleDescription
InstanceIdTargetParameterYesThe ID of the instance that you specify when the event target is ApsaraMQ for RabbitMQ.
ValueStringYesamqp-cn-2r42e73o****The ID of the ApsaraMQ for RabbitMQ instance. For more information, see Limits.
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.
VirtualHostNameTargetParameterYesThe name of the vhost in the ApsaraMQ for RabbitMQ instance.
ValueStringYesrabbit-hostThe name of the vhost in the ApsaraMQ for RabbitMQ instance. For more information, see Limits.
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.
TargetTypeTargetParameterYesThe type of the resource to which events are to be pushed.
ValueStringYesExchange/QueueThe type of the resource to which events are to be pushed. Valid values:
  • Exchange
  • Queue
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.
ExchangeTargetParameterYesThe name of the exchange to which events are to be pushed in the destination instance.

This parameter is valid only when you set the TargetType parameter to Exchange.

ValueStringYesa_exchangeThe name of the exchange in the ApsaraMQ for RabbitMQ instance. For more information, see Limits.
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.
RoutingKeyTargetParameterYesThe routing rule for the message.

This parameter is valid only when you set the TargetType parameter to Exchange.

ValueStringYeshousekeepingThe routing rule for the message.
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.
QueueNameTargetParameterYesThe name of the queue to which events are pushed in the destination instance.

This parameter is valid only when you set the TargetType parameter to Queue.

ValueStringYesMyQueueThe name of the queue in the Message Queue for RabbitMQ instance. For more information, see Limits.
FormStringNoCONSTANTThe transformation method. Default value: CONSTANT.
BodyTargetParameterYesThe content of the message.
FormStringNoTEMPLATEThe transformation method.
ValueStringYes
{
  "key": "value"
}
The value before the transformation.
TemplateStringNoThe value of ${key} is ${value}!The template based on which events are to be transformed.
MessageIdTargetParameterYesThe ID of the message.
ValueStringYes
{
  "key": "value"
}
The value before the transformation.
FormStringNoTEMPLATEThe transformation method.
TemplateStringYesThe value of ${key} is ${value}!The template based on which events are to be transformed.
PropertiesTargetParameterYesThe tags that are used to filter messages.
ValueStringYes
{
  "key": "value"
}
The value before the transformation.
FormStringNoTEMPLATEThe transformation method.
TemplateStringYesThe value of ${key} is ${value}!The template based on which events are to be transformed.

Request parameter SinkSLSParameters

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

ParameterTypeRequiredExampleDescription
ProjectStringYestest-projectThe Log Service project.
LogStoreStringYestest-logstoreThe Log Service Logstore.
TopicStringNotestTopicThe topic in which the log resides. The value of this parameter is the same as the value of the reserved field "__topic__" in Log Service.
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.

Response parameters

ParameterTypeExampleDescription
EventStreamingARNStringacs:eventbridge:cn-hangzhou:164901546557****:eventstreaming/myeventstreamingThe ARN of the EventStreaming.

Examples

In the following sample requests and responses, events are routed from the custom event source of the ApsaraMQ for RocketMQ type to the event target Simple Message Queue (formerly MNS).

Sample requests

POST /eventstreaming/creatEventStreaming 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

{
    "EventStreamingName":"myeventstreaming",
    "Description":"rocketmq2mns",
    "FilterPattern":"{}",
    "Source":{
        "SourceRocketMQParameters":{
            "InstanceId":"MQ_INST_164901546557****_BAAN****",
            "GroupID":"GID_group1",
            "Topic":"mytopic",
            "Offset":"CONSUME_FROM_TIMESTAMP",
            "Tag":"",
            "RegionId":"cn-hangzhou",
            "Timestamp":1636597951964
        }
    },
    "Sink":{
        "SinkMNSParameters":{
            "QueueName":{
                "Value":"MyQueue",
                "Form":"CONSTANT"
            },
            "IsBase64Encode":{
                "Value":"true",
                "Form":"CONSTANT"
            },
            "Body":{
                "Value":{
                    "key":"value"
                },
                "Form":"TEMPLATE",
                "Template":"The value of ${key} is ${value}!"
            }
        }
    },
    "RunOptions":{
        "ErrorsTolerance":"ALL",
        "RetryStrategy":{
            "PushRetryStrategy":"BACKOFF_RETRY"
        },
        "DeadLetterQueue":{
            "Arn":"acs:mq:cn-chengdu:164901546557****:/instances/MQ_INST_164901546557****_BXxk0KXx/topic/Mytopic"
        }
    }
}

Sample responses

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":{
            "EventStreamingARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventstreaming/myeventstreaming"
        },
        "Code":"Success",
        "Success":true
    },
    "httpStatusCode":"200",
    "requestId":"244BED53-719A-15D7-B7F9-1C404273****",
    "successResponse":true
}