-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HandleRequestCollectionHelper for Quarkus Amazon Lambda #40349
Comments
/cc @matejvasek (amazon-lambda), @patriot1burke (amazon-lambda) |
@scrocquesel maybe this is also interesting for you |
It would be better to change the reader created by the object mapper here: To use ObjectMapper.readerFor(TypeReference) |
@patriot1burke Do you have an idea how this can be done in the linked class? |
Yeah, Line 55 in 1323185
I think that will work. Should do the same for the writer too. Also, probably need to handle the case where the handler class is parameterized. |
Description
Hello.
We run several quarkus application as AWS Lambdas. Some are triggered by an AWS Api gateway and some by sqs or sns. A queue can collect some messages and send them via batching to a lambda. In JSON this would look like this if the message has a name and description attribute.
A RequestHandler would look like this:
When this runs sadly an exception occurs.
The ObjectMapper cannot infer the correct type and as fallback uses a LinkedHashMap.
This can be solved with a little trick and this is my enhancement idea...
With HandleRequestCollectionHelper the subclass is forced to implement getCollectionReference so that the ObjectMapper is able to convert the LinkedHashMap to the Collection-Type. If this is done inside a HandleRequestHelper this is hidden from the developer. Maybe getCollectionReference can also be saved with some reflection magic because the type should be already there in the INPUT_TYPE parameter.
HandleRequestCollectionHelper could be added to the amazon-lambda lib. Or maybe automatically used if a Collection-Type is used in first parameter of implementation of RequestHandler-Interface.
I have a simple example here https://github.com/hamburml/quarkus-lambda-handler-with-collection Under src/test are two packages, working and notworking.
Let me know what you think of that.
Thanks
Michael
The text was updated successfully, but these errors were encountered: