[英]Send a lot of SQS messages in a lambda without getting timed out
I have an array, lets say with a length of 9999. Now I want to send a message to SQS with the contents of each object in the array.我有一个数组,假设长度为 9999。现在我想向 SQS 发送一条消息,其中包含数组中每个 object 的内容。
Here is how I want to send the messages:这是我要发送消息的方式:
const promises = tokens.map((token) => {
const params = {
Body: JSON.stringify(data),
};
return sqs.sendMessage({
MessageBody: JSON.stringify(params),
QueueUrl: 'my-queue-url',
}).promise();
});
await Promise.all(promises);
Now, the problem is that I trigger this function via API Gateway, which times out after 30 seconds.现在,问题是我通过 API 网关触发了这个 function,它在 30 秒后超时。 How can I avoid this?
我怎样才能避免这种情况? Is there a better way to do this?
有一个更好的方法吗?
Based on your response in the comments I suggest you do two things:根据您在评论中的回复,我建议您做两件事:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.