如何从基于 Micronaut 的 AWS Lambda 连接本地 Oracle DB
我正在尝试使用 micronaut 进行基于 Java 的无服务器(AWS lambda)开发。 第一个用例是连接并查询本地 Oracle DB(用于只读操作)以丰富数据,然后调用一些肥皂服务。
这个问题是关于在本地进行 Oracle DB 调用。我在互联网上看到了一些基于连接池的方法的参考(JDBC-hikari 等),这可能是 lambda 应用程序不需要的。那么使用 micronaut 连接/调用/关闭 Oracle 连接的最佳/推荐方法是什么? 请建议。
I am trying to get on micronaut for my Java based serverless (AWS lambda) development.
First use case is connect and query onpremise oracle DB (for read only operations) to enrich the data and then call some soap services.
This question is about making Oracle DB call onpremise. I see some references of connection pool based approach on internet (JDBC-hikari etc) which might not needed for lambda app. So what would be best/recommended way to connect/call/close oracle connection using micronaut?
Please suggest.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管要实现此功能需要考虑很多网络因素,但我认为您是在具体询问连接池。
您的想法是正确的,您的 Lambda 函数可能不会从拥有许多开放连接中受益。根据工作量,您实际上可能只需要一个。
我建议在 Lambda 初始化阶段建立连接。然后,连接将在调用之间保持不变。要在 Lambda 执行环境终止之前关闭连接,您可以注册运行时关闭挂钩。
此 AWS GitHub 存储库中有一个示例 使用 aws-lambda 优雅关闭。
Although there will be lots of networking considerations for this to work, I think you're asking specifically about the connection pooling.
You're correct in thinking that your Lambda function probably won't benefit from having many open connections. Depending on the work load you may in fact just want one.
I would recommend that a connection is made during the Lambda init phase. The connection will then persist between invokes. To close the connection before the Lambda execution environment is terminated you can register a runtime shutdown hook.
There is an example in this AWS GitHub repo graceful-shutdown-with-aws-lambda.