如何使用Open JDK 11+作为自定义运行时执行AWS Lambda? [英] How to execute AWS lambda with Open JDK 11+ as custom runtime?

查看:189
本文介绍了如何使用Open JDK 11+作为自定义运行时执行AWS Lambda?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AWS允许使用Java 8( OpenJDK 8 )作为运行时来创建 Lambda函数. 我需要使用Open JDK 11创建一个简单的函数.像这样的东西:

AWS allows to create Lambda function with Java 8 (OpenJDK 8) as runtime. I need to create a simple function using Open JDK 11. Something like that:

package example;

import com.amazonaws.services.lambda.runtime.Context; 
import com.amazonaws.services.lambda.runtime.LambdaLogger;

public class Hello {
    public String myHandler(int myCount, Context context) {
        LambdaLogger logger = context.getLogger();
        logger.log("received : " + myCount);
        return String.valueOf(myCount);
    }
}

有一个选项允许使用自定义运行时和教程,其中包含Shell的示例.但是,没有Java的示例.

There is an option allowing to use a custom runtime and a tutorial that contains an example with Shell. However there is no example with Java.

有人用自定义Java运行时处理过AWS Lambda吗?

Is anyone have already deal with an AWS lambda with custom java runtime?

推荐答案

我也很好奇为什么我们还没有看到Java的任何自定义运行时,所以大约一个月前,我开始尝试构建Java 11中的一种使用Jigsaw生成较小的运行时.尽管它不完全是一个教程,但我确实编写了有关如何构建它的相当详细的自述文件,并且代码很简单,可以遵循.

I was also curious as to why we haven't seen any custom runtimes for Java yet, so about a month ago I started playing around with the idea of building one in Java 11 using Jigsaw to produce small runtime. While it's not exactly a tutorial, I did write a fairly detailed Readme on how to build this and the code is simple enough to follow.

这是我在GitHub上的项目:

Here's my project on GitHub:

https://github.com/andthearchitect/aws-lambda-java-runtime

我最近才出版了此书,它肯定是POC,因此使用时需您自担风险.

I just published this recently and it's most certainly a POC so use at your own risk.

Corretto似乎很有趣,但是我想仍然会有一些人对OpenJDK的官方发行版更加满意.我希望这可以成为可用于Java的生产就绪型开源运行时的起点.

Corretto seems interesting but I would guess there will still be people out there who are more comfortable with the official OpenJDK release. I'm hoping maybe this can be the starting point for a production ready open source runtime for Java.

这篇关于如何使用Open JDK 11+作为自定义运行时执行AWS Lambda?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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