SQS lambda 总是调用 3 次,不知道为什么?在无服务器 aws 上
SQS lambda invokes 3 times always, don't know why? on serverless aws
这是用 node js 编写的队列消费者代码
const consumer = async (event) => {
console.log(event)
for (const record of event.Records) {
const reqBody = JSON.parse(record.body);
console.log(reqBody);
}
return true;
};
- 我在博客上的某个地方读到,当我 return 为真(其他)时,队列消息会自动删除。
- 这些是我对相同
messageId
的调用...但不同 receiptHandle
这里您观察到 lambda 函数每 2 秒调用一次
- 有关更多信息,我还添加了 serverless.yml 文件代码
constructs:
jobs:
type: queue
worker:
timeout: 20
handler: handler.consumer
我正在使用无服务器框架这是无服务器团队的官方回应 ->
enter image description here
I assume you are referring to an SQS queue? You would need to delete the message yourself as SQS does not automatically delete messages: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-using-receive-delete-message.html
这是用 node js 编写的队列消费者代码
const consumer = async (event) => {
console.log(event)
for (const record of event.Records) {
const reqBody = JSON.parse(record.body);
console.log(reqBody);
}
return true;
};
- 我在博客上的某个地方读到,当我 return 为真(其他)时,队列消息会自动删除。
- 这些是我对相同
messageId
的调用...但不同receiptHandle
这里您观察到 lambda 函数每 2 秒调用一次
- 有关更多信息,我还添加了 serverless.yml 文件代码
constructs:
jobs:
type: queue
worker:
timeout: 20
handler: handler.consumer
我正在使用无服务器框架这是无服务器团队的官方回应 -> enter image description here
I assume you are referring to an SQS queue? You would need to delete the message yourself as SQS does not automatically delete messages: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-using-receive-delete-message.html