我有一个带SQS触发器的Lambda。当它被触发时,来自SQS的一批记录会进入(通常一次约有10个)。如果我从处理程序返回失败状态代码,则所有10条消息都将重试。如果我返回成功代码,则它们将全部从队列中删除。如果这10条消息中有1条失败了,并且我想重试只有那一条,该怎么办?
exports.handler = async (event) => {
for(const e of event.Records){
try {
let body = JSON.parse(e.body);
// do things
}
catch(e){
// one message failed, i want it to be retried
}
}
// returning this causes ALL messages in
// this batch to be removed from the queue
return {
statusCode: 200,
body: 'Finished.'
};
};
我需要手动将那个消息重新添加到队列吗?还是可以从我的处理程序返回一个指示一个消息失败应该重试的状态?