This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7a2067c7e1dc09809ae89007b97d7a92138ef97e Author: Andrea Cosentino <[email protected]> AuthorDate: Mon Apr 20 12:19:10 2020 +0200 CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-lambda invoke function --- .../camel/component/aws2/lambda/Lambda2Producer.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java index 821d490..5a532a7 100644 --- a/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java +++ b/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java @@ -232,7 +232,21 @@ public class Lambda2Producer extends DefaultProducer { } } - private void invokeFunction(LambdaClient lambdaClient, Exchange exchange) { + private void invokeFunction(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException { + if (getConfiguration().isPojoRequest()) { + Object payload = exchange.getIn().getMandatoryBody(); + if (payload instanceof InvokeRequest) { + InvokeResponse result; + try { + result = lambdaClient.invoke((InvokeRequest) payload); + } catch (AwsServiceException ase) { + LOG.trace("invokeFunction command returned the error code {}", ase.awsErrorDetails().errorCode()); + throw ase; + } + Message message = getMessageForResponse(exchange); + message.setBody(result.payload().asUtf8String()); + } + } else { InvokeResponse result; try { InvokeRequest request = InvokeRequest.builder().functionName(getEndpoint().getFunction()) @@ -244,6 +258,7 @@ public class Lambda2Producer extends DefaultProducer { } Message message = getMessageForResponse(exchange); message.setBody(result.payload().asUtf8String()); + } } @SuppressWarnings("unchecked")
