即使将响应发送到API网关后,AWS Lambda仍可在后台运行 [英] AWS Lambda to run in background even after sending response to API Gateway

查看:98
本文介绍了即使将响应发送到API网关后,AWS Lambda仍可在后台运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上搜索了所有内容,但没有找到如何使此功能成功的解决方案.需要帮助.

I have searched all through the net but didn't find a solution of how to make this functionality get succeeded. Require help.

我的要求是:如果要触发以node.js编写的aws lambda函数并使用aws-serverless-express模块​​,则必须快速将响应发送回API网关,但仍不应退出并仍在其中运行后端,我们可以看到云监视日志.它必须是异步的.

My requirement is: I want a that if I trigger an aws lambda function written in node.js and uses an aws-serverless-express module must send back response quickly to API gateway but still should not exit and still run in the backend and we could see cloud watch logs. It must be asynchronous.

代码段为:

    app.get('/check', function(req, res){
     method.invoke(req)
     res.status(200).send('success')
   })

我这样做并进行了检查,但是lambda函数被停止并将响应返回到api网关,该网关甚至没有在后端运行method.invoke()函数.

I did and checked like this but the lambda function gets stopped and returns the response to api gateway it didn't even runs the method.invoke() function in backend.

如果我理解或做错了任何事情,请纠正我.我检查了以下链接:调用AWS Lambda并返回响应异步访问API网关

Please correct me if anything I am understanding or doing wrong. I checked with this link: Invoke AWS Lambda and return response to API Gateway asyncronously

这是解决此问题的唯一方法.创建两个lambda函数.

Is it the only way to do this problem. Creating two lambda functions.

推荐答案

您可以使用

You can achieve this by using AWS Lambda Step functions, connected to API Gateway, having parallel execution of branches with two lambda functions, where one returns a response to API Gateway and other executes asynchronously.

这篇关于即使将响应发送到API网关后,AWS Lambda仍可在后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆