SQS 事件桥每分钟一次

SQS Event Bridge Once Per Minute

我们正在研究 Event Bridge,以便每分钟向我们的 SQS 添加一次计划任务。

我们正在寻找 Event Bridge 来实现它。到目前为止,它正确地将消息放入队列中,但我们正在尝试将其安排为每分钟一次,并注意到队列每五分钟仅接收一次消息,有时是六分钟。

指标似乎表明正在调用;但是,队列没有在指定的时间范围内接收它们。

注意事项

在规定的时间间隔看不到​​消息的“废话”是因为 AWS 文档中的这个:

The token used for deduplication of sent messages. If a message with a particular message deduplication ID is sent successfully, any messages sent with the same message deduplication ID are accepted successfully but aren’t delivered during the 5-minute deduplication interval

接受建议并将寻找解决方法。

更新

我尝试使用 Input Transformer 将时间添加为队列消息中的唯一更改项来修复;但是,仍然没有低于 5 分钟。

变量输入

{"addedOn":"$.time"}

留言

{"AddedOn":<addedOn>}

SQS 中内置的队列轮询不会轮询我更新的大于 10 条消息的计数。一旦我删除了旧消息,时间就正确了,它正在更新 1/分钟。

答案是,如果您要使用常量字符串,则它必须用于超过 5 分钟的计划作业。

尽管链接 Google 搜索的问题存在冗余,但还是在此处添加信息:

The token used for deduplication of sent messages. If a message with a particular message deduplication ID is sent successfully, any messages sent with the same message deduplication ID are accepted successfully but aren’t delivered during the 5-minute deduplication interval

尽管消息是每分钟一次的唯一事件,但常量(JSON 文本)不是唯一的,仍然将其视为要删除的副本。

为了解决我切换到输入变压器

示例事件以及您可以添加为变量的其他字段:

{
 "version": "0",
 "id": "7bf73129-1428-4cd3-a780-95db273d1602",
 "detail-type": "EC2 Instance State-change Notification",
 "source": "aws.ec2",
 "account": "123456789012",
 "time": "2015-11-11T21:29:54Z",
 "region": "us-east-1",
 "resources": [
 "arn:aws:ec2:us-east-1:123456789012:instance/i-abcd1111"
 ],
 "detail": {
 "instance-id": "i-0123456789",
 "state": "RUNNING"
 }
}

我需要一个独特的变量,所以时间是一个显而易见的选择。

输入变压器的输入

输入路径:

{"addedOn":"$.time"}

模板:

{"AddedOn":<addedOn>}

Documentation

此外,如果这对于未来的 SQS 开发人员来说也是一个简单的选择,那么转向不使用 FIFO 队列是一个潜在的解决方案。