spring-cloud-function-aws-example | An example for Spring Cloud Function Aws | Microservice library
kandi X-RAY | spring-cloud-function-aws-example Summary
kandi X-RAY | spring-cloud-function-aws-example Summary
An example repository for an article about running Spring Cloud Functions on AWS Lambda. The article is available here:
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Returns uppercase response
- Gets the user input
- Sets the result
- Converts a string to uppercase
- The main method
spring-cloud-function-aws-example Key Features
spring-cloud-function-aws-example Examples and Code Snippets
Community Discussions
Trending Discussions on spring-cloud-function-aws-example
QUESTION
I'm building a lambda based on this code
The uppercaseService is "injected" like this:
...ANSWER
Answered 2018-May-21 at 13:27You have to initialize your MyService
bean first. Since your MyService
come from external service which very likely to have different package than your own package
Either directly:
QUESTION
I'm new to Java/AWS etc., and AWS lambda we not de-serialize what I think is a trivial example.
The API Gateway log, which is sending JSON to my lambda:
Execution log for request test-request Mon Sep 11 18:04:06 UTC 2017 : Starting execution for request: test-invoke-request Mon Sep 11 18:04:06 UTC 2017 : HTTP Method: POST, Resource Path: / Mon Sep 11 18:04:06 UTC 2017 : Method request path: {} Mon Sep 11 18:04:06 UTC 2017 : Method request query string: {} Mon Sep 11 18:04:06 UTC 2017 : Method request headers: {Content-Type=application/json} Mon Sep 11 18:04:06 UTC 2017 : Method request body before transformations: {"input":"richard was here"} Mon Sep 11 18:04:06 UTC 2017 : Endpoint request URI: https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-2:003374398906:function:uppertolowercase/invocations Mon Sep 11 18:04:06 UTC 2017 : Endpoint request headers: {x-amzn-lambda-integration-tag=test-request, Authorization=****************************************************************************************************************************************************************************************************************************************************************************************************************************************8acc24, X-Amz-Date=20170911T180406Z, x-amzn-apigateway-api-id=8fjgcr51va, X-Amz-Source-Arn=arn:aws:execute-api:us-west-2:003374398906:8fjgcr51va/null/POST/, Accept=application/json, User-Agent=AmazonAPIGateway_8fjgcr51va, X-Amz-Security-Token=xxxxxxx//////////wEaDM3BrDjbuGSwMFT5lCK3AyBVM7duW9tzEe/bcWqWiYNIxkpMjTdDZaW3U32asJ4qvntUsRpjfSIhLWAds74XhzHbI7GzXMuV3zQYCIiYRX0ZL1s524J7mETGFN4OredlGln7CCEs3WR417UaPB4XLh6E0v71Srpg4a1kG7KB6426gN9CvXR0mmYbwpl9qtp9bovLgIoVnjYbx5j7qd7Fa3U4wQOqcHonlKtN/uDXMFW+vfHOJyu3gQUyvoVpMuXrQSF/gptEXG+l0v4+v1exq67sp8G5d8h1kAQTNQep8Q19kyOi9hWbNDyU7FzXWvfSRX7f9n6NGIuZ6LYIF3g2kPFY [TRUNCATED] Mon Sep 11 18:04:06 UTC 2017 : Endpoint request body after transformations: {"input":"richard was here"} Mon Sep 11 18:04:06 UTC 2017 : Sending request to https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-2:003374398906:function:uppertolowercase/invocations Mon Sep 11 18:04:06 UTC 2017 : Received response. Integration latency: 73 ms Mon Sep 11 18:04:06 UTC 2017 : Endpoint response body before transformations: {"errorMessage":"java.util.LinkedHashMap cannot be cast to com.morethanheroic.uppercase.domain.UppercaseRequest","errorType":"java.lang.ClassCastException","stackTrace":["com.morethanheroic.uppercase.UppercaseFunction.apply(UppercaseFunction.java:13)","org.springframework.cloud.function.support.FluxFunction.lambda$apply$0(FluxFunction.java:42)","reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107)","reactor.core.publisher.FluxJust$WeakScalarSubscription.request(FluxJust.java:90)","reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:159)","reactor.core.publisher.BlockingIterable$SubscriberIterator.onSubscribe(BlockingIterable.java:214)","reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)","reactor.core.publisher.FluxJust.subscribe(FluxJust.java:67)","reactor.core.publisher.FluxMapFuseable.subscribe(FluxMapFuseable.java:63)","reactor.core.pu [TRUNCATED] Mon Sep 11 18:04:06 UTC 2017 : Endpoint response headers: {x-amzn-Remapped-Content-Length=0, x-amzn-RequestId=9a0ca35b-971b-11e7-b0d0-653f3fe89968, Connection=keep-alive, Content-Length=1557, X-Amz-Function-Error=Unhandled, Date=Mon, 11 Sep 2017 18:04:05 GMT, X-Amzn-Trace-Id=root=1-59b6d016-3a1ae0e3274a3e84e451bf13;sampled=0, Content-Type=application/json} Mon Sep 11 18:04:06 UTC 2017 : Method response body after transformations: {"errorMessage":"java.util.LinkedHashMap cannot be cast to com.morethanheroic.uppercase.domain.UppercaseRequest","errorType":"java.lang.ClassCastException","stackTrace":["com.morethanheroic.uppercase.UppercaseFunction.apply(UppercaseFunction.java:13)","org.springframework.cloud.function.support.FluxFunction.lambda$apply$0(FluxFunction.java:42)","reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107)","reactor.core.publisher.FluxJust$WeakScalarSubscription.request(FluxJust.java:90)","reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:159)","reactor.core.publisher.BlockingIterable$SubscriberIterator.onSubscribe(BlockingIterable.java:214)","reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)","reactor.core.publisher.FluxJust.subscribe(FluxJust.java:67)","reactor.core.publisher.FluxMapFuseable.subscribe(FluxMapFuseable.java:63)","reactor.core.publi [TRUNCATED] Mon Sep 11 18:04:06 UTC 2017 : Method response headers: {X-Amzn-Trace-Id=sampled=0;root=1-59b6d016-3a1ae0e3274a3e84e451bf13, Content-Type=application/json} Mon Sep 11 18:04:06 UTC 2017 : Successfully completed execution Mon Sep 11 18:04:06 UTC 2017 : Method completed with status: 200
I'm using this JSON to provide data to be de-serialized to the following POJO
...ANSWER
Answered 2017-Sep-13 at 07:44It works for me if I specify the handler in the right way (com.morethanheroic.uppercase.handler.aws.UppercaseFunctionHandler
in this case):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-cloud-function-aws-example
You can use spring-cloud-function-aws-example like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the spring-cloud-function-aws-example component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page