Creates an event rule.
Operation description
Creates an event rule.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
eventbridge:CreateRule |
create |
*Rule
|
None | 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. |
SMQ的过滤规则 |
| RuleName |
string |
Yes |
The name of the event rule. |
MNSRule |
| Status |
string |
No |
The status of the rule. Valid values: ENABLE: The rule is enabled. This is the default value. DISABLE: The rule is disabled. |
ENABLE |
| FilterPattern |
string |
Yes |
The event pattern, in JSON format. Valid values: stringEqual pattern. stringExpression pattern. Each field can have up to five expressions in a map structure. |
{\"source\": [{\"prefix\": \"acs.\"}],\"type\": [{\"prefix\":\"oss:ObjectReplication\"}],\"subject\":[{\"prefix\":\"acs:oss:cn-hangzhou:123456789098****:my-movie-bucket/\", \"suffix\":\".txt\"}]} |
| EventTargets |
array<object> |
No |
The list of event targets. |
|
|
array<object> |
No |
An event target. |
||
| Id |
string |
Yes |
The custom 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 to which events are delivered. |
acs:mns:cn-hangzhou:123456789098****:queues/myqueue |
| PushRetryStrategy |
string |
No |
The retry policy for pushing events. Valid values: BACKOFF_RETRY: Backoff retry. The system retries pushing an event three times. The interval between two consecutive retries is a random value between 10 seconds and 20 seconds. EXPONENTIAL_DECAY_RETRY: Exponential decay retry. The system retries pushing an event 176 times. The interval between two consecutive retries exponentially increases to 512 seconds. 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. The interval is 512 seconds for the last 167 retries. |
BACKOFF_RETRY |
| DeadLetterQueue |
object |
No |
The dead-letter queue. Events that are not processed or exceed the number of retries are written to the dead-letter queue. The dead-letter queue can be a Message Queue for Apache RocketMQ queue, a Simple Message Queue (formerly MNS) queue, a Message Queue for Apache Kafka topic, or an EventBridge event bus. |
|
| Arn |
string |
No |
The Alibaba Cloud Resource Name (ARN) of the dead-letter queue. Events that are not processed or exceed the number of retries are written to the dead-letter queue. Simple Message Queue (formerly MNS) and Message Queue for Apache RocketMQ are supported. |
acs:mns:cn-hangzhou:123456789098****:/queues/rule-deadletterqueue |
| Network |
string |
No |
||
| VpcId |
string |
No |
||
| VSwitchIds |
string |
No |
||
| SecurityGroupId |
string |
No |
||
| ErrorsTolerance |
string |
No |
The fault tolerance policy. Valid values: ALL: Fault tolerance is allowed. If an error occurs, the execution is not blocked. After the retry policy is exhausted, the message is delivered to a dead-letter queue or discarded. NONE: Fault tolerance is not allowed. If an error occurs and the retry policy is exhausted, the execution is blocked. |
ALL |
| ParamList |
array<object> |
No |
The parameters of the event target. |
|
|
object |
No |
The parameters of the event target. |
||
| ResourceKey |
string |
No |
The resource parameter of the event target. For more information, see Limits. |
body |
| Form |
string |
No |
The format of the event target parameter. For more information, see Limits. |
TEMPLATE |
| Value |
string |
No |
The value of the event target parameter. |
{\"key\"=\"value\"} |
| Template |
string |
No |
The template of the event target parameter. |
The value of ${key} is ${value}! |
| ConcurrentConfig |
object |
No |
The concurrency control configuration. |
|
| Concurrency |
integer |
No |
The concurrency. |
2 |
Sample request
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":"The filter 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\"}]}", "EventTargets":[ { "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 elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Message |
string |
The error message. |
Remote error. requestId: [xxxx], error code: [xxx], message: [The target in event rule is invalid! Endpoint is xxx |
| RequestId |
string |
The request ID. |
1AD6D598-7506-5D2C-81EA-30E3241A903A |
| Data |
object |
The returned data. |
|
| RuleARN |
string |
The ARN of the event rule. This is used for authorization. |
acs:eventbridge:cn-hangzhou:123456789098****:eventbus/default/rule/MNSRule |
| Code |
string |
The response code. A value of 200 indicates that the request is successful. For more information about other error codes, see Error codes. |
200 |
| Success |
boolean |
A value of `true` indicates that the call is successful. |
true |
Examples
Success response
JSON format
{
"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 |
Description |
|---|---|---|---|
| 403 | ServiceNotEnable | Service not enable |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.