Reputation: 81
I'e read AWS Lambda documentation for Quarkus ad it looks pretty interesting.
I'd like to deploy on AWS some Quarkus native lambda as explained here https://aws.amazon.com/blogs/architecture/field-notes-optimize-your-java-application-for-aws-lambda-with-quarkus/, my goal is to leverage Java ecosystem power (and not have JS NPM based Lambda) and still having very low cold and warm execution time, in order to lower AWS billing.
I do not want to code the logic who maps the requests on the right "controller's" method, like this :
[...]
switch (httpMethod) {
case "GET":
Map<String, String> queryStringParameters = request.getQueryStringParameters();
String userId = null;
if (pathParameters != null)
userId = pathParameters.get("userId");
else if (queryStringParameters != null)
userId = queryStringParameters.get("userId");
if (userId == null || userId.length() == 0) {
LOGGER.info("Getting all users");
userList = userService.findAll();
LOGGER.info("GET: " + userList);
try {
result = mapper.writeValueAsString(userList);
} catch (JsonProcessingException exc) {
LOGGER.error(exc);
}
[...]
Too expensive to code and error prone, it's a show stopper for me
Rather I'd like to leverage a mechanism such as the one described here https://aws.amazon.com/blogs/opensource/java-apis-aws-lambda/ : long story short the Lambda Handler maps the Lambda input data (Stream, Context, etc..) to a Http Request and the JAX-RS implementation does the rest of the work, or something similar, responsibilities are not completely clear to me.
This is very interesting because you can continue write your controllers as always, with annotation and all the stuff and your lambda stays very simple and just maps the objects :
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
throws IOException {
handler.proxyStream(inputStream, outputStream, context);
Do a ProxyStream implementation exist for Jersey, Spring and other framework, do a similar ProxyImplementation exist for Quarkus JAX-RS implementation (Jackson ?)
Upvotes: 4
Views: 869
Reputation: 389
You could look into the quarkus lambda rest extension, that does exactly that for jaxrs. However you can't currently have both stream based requests like from s3/sqs AND http based ones. This is what i am struggling with and i think i will do the manual mapping thing you mentioned.
Upvotes: 2