Creates an event rule.
Operation description
You can call this API operation to create an event rule.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- For mandatory resource types, indicate with a prefix of * .
- If the permissions cannot be granted at the resource level,
All Resourcesis used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
| Operation | Access level | Resource type | Condition key | Associated operation |
|---|---|---|---|---|
| eventbridge:CreateRule | create | *Rule acs:eventbridge:{#regionId}:{#accountId}:eventbus/{#EventBusName}/rule/{#RuleName} |
| none |
Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| EventBusName | string | Yes | The name of the event bus. | MyEventBus |
| Description | string | No | The description of the event bus. | |
| RuleName | string | Yes | The name of the event rule. | MNSRule |
| Status | string | No | The status of the event rule. Valid values: ENABLE: enables the event rule. It is the default status of the event rule. DISABLE: disables the event rule. | ENABLE |
| FilterPattern | string | Yes | The event pattern, in JSON format. Valid values: stringEqual and stringExpression. You can specify up to five expressions in the map data structure in each field. You can specify up to five expressions in the map data structure in each field. | {\"source\": [{\"prefix\": \"acs.\"}],\"type\": [{\"prefix\":\"oss:ObjectReplication\"}],\"subject\":[{\"prefix\":\"acs:oss:cn-hangzhou:123456789098****:my-movie-bucket/\", \"suffix\":\".txt\"}]} |
| EventTargets | array<object> | Yes | The event targets. | |
| object | Yes | The event target. | ||
| Id | string | Yes | The ID of the event target. | 12021 |
| Type | string | Yes | The type of the event target. For more information, see Event target parameters. | acs.mns.queue |
| Endpoint | string | No | The endpoint of the event target. | acs:mns:cn-hangzhou:123456789098****:queues/myqueue |
| PushRetryStrategy | string | No | The retry policy that you want to use to push failed events. Valid values: BACKOFF_RETRY and EXPONENTIAL_DECAY_RETRY. BACKOFF_RETRY: A failed event can be retried up to three times. The interval between two consecutive retries is a random value from 10 seconds to 20 seconds. EXPONENTIAL_DECAY_RETRY: A failed event can be retried up to 176 times. The interval between two consecutive retries exponentially increases to a maximum of 512 seconds. The total retry time is 1 day. The specific retry intervals are 1, 2, 4, 8, 16, 32, 64, 128, 256, and 512 seconds. The interval of 512 seconds is used for 167 retries. | BACKOFF_RETRY |
| DeadLetterQueue | object | No | The dead-letter queue. Events that are not processed or whose maximum number of retries is exceeded are written to the dead-letter queue. You can use queues in ApsaraMQ for RocketMQ, Simple Message Queue (SMQ, formerly MNS), and ApsaraMQ for Kafka as dead-letter queues. You can also use event buses in EventBridge as dead-letter queues. | |
| Arn | string | No | The Alibaba Cloud Resource Name (ARN) of the dead-letter queue. Events that are not processed or whose maximum number of retries is exceeded are written to the dead-letter queue. Queues in SMQ and ApsaraMQ for RocketMQ can be used as dead-letter queues. | acs:mns:cn-hangzhou:123456789098****:/queues/rule-deadletterqueue |
| ErrorsTolerance | string | No | The fault tolerance policy. Valid values: ALL and NONE. The value ALL specifies that fault tolerance is allowed. If an error occurs in an event, event processing is not blocked. If the event fails to be sent after the maximum number of retries specified by the retry policy is reached, the event is delivered to the dead-letter queue or discarded based on your configurations. The value NONE specifies that fault tolerance is not allowed. If an error occurs in an event and the event fails to be sent after the maximum number of retries specified by the retry policy is reached, event processing is blocked. | ALL |
| ParamList | array<object> | No | The parameters that are configured for the event target. | |
| object | No | The parameters that are configured for the event target. | ||
| ResourceKey | string | No | The resource key of the event target. For more information, see Limits . | body |
| Form | string | No | The format of input parameters for the event target. For more information, see Limits . | TEMPLATE |
| Value | string | No | The value of the event target parameter. | {\"key\"=\"value\"} |
| Template | string | No | The structure of the template for the event target. | The value of ${key} is ${value}! |
| ConcurrentConfig | object | No | The concurrency configuration. | |
| Concurrency | long | No | The concurrency. | 2 |
Sample requests
POST /openapi/createRule HTTP/1.1 Host: 123456789098****.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
{ "EventBusName":"default", "RuleName":"MNSRule", "Description":"Filtering rule for MNS", "Status":"ENABLE", "filterPattern":"{"source": [{"prefix": "acs."}],"type": [{"prefix":"oss:ObjectReplication"}],"subject":[{"prefix":"acs:oss:cn-hangzhou:123456789098****:my-movie-bucket/", "suffix":".txt"}]}", "Targets":[ { "Id":"1", "Type":"acs.mns.queue", "Endpoint":"acs:mns:cn-hangzhou:123456789098****:queues/myqueue", "PushRetryStrategy":"BACKOFF_RETRY", "DeadLetterQueue":{ "Arn":"acs:mns:cn-hangzhou:123456789098****:/queues/rule-deadletterqueue" }, "ParamList":[ { "resourceKey":"queue", "form":"CONSTANT", "value":"myqueue" }, { "resourceKey":"body", "form":"TEMPLATE", "value":"{"key"="value"}", "template":"The value of ${key} is ${value}!" } ] } ] }
Response parameters
Examples
Sample success responses
JSONformat
{
"Message": "Remote error. requestId: [xxxx], error code: [xxx], message: [The target in event rule is invalid! Endpoint is xxx",
"RequestId": "1AD6D598-7506-5D2C-81EA-30E3241A903A",
"Data": {
"RuleARN": "acs:eventbridge:cn-hangzhou:123456789098****:eventbus/default/rule/MNSRule"
},
"Code": 200,
"Success": true
}Error codes
| HTTP status code | Error code | Error message |
|---|---|---|
| 403 | ServiceNotEnable | Service not enable |
For a list of error codes, visit the Service error codes.
Change history
| Change time | Summary of changes | Operation |
|---|---|---|
| 2024-09-25 | The Error code has changed | View Change Details |
