I am having two AWS lambda java 8 function "lambda A" and "lambda B". "lambda A" function invokes "lambda B" function and waits till it gets the result of "lambda B". But I want to invoke the "lambda B" and return the "lambda A" function immediately. Is it possible to implement and any reference links related to it.
1 Answer
With the AWS Lambda SDK for Java you can set the InvocationType within the InvokeRequest object. This will just invoke your function, but won't wait for a response.
From the Javadocs:
By default, the Invoke API assumes RequestResponse invocation type. You can optionally request asynchronous execution by specifying Event as the InvocationType.
Example:
AWSLambda lambdaClient = AWSLambdaClientBuilder.defaultClient();
InvokeRequest request = new InvokeRequest();
request.withFunctionName(name)
.withInvocationType(InvocationType.Event)
.withPayload(payload);
InvokeResult result = lambdaClient.invoke(request);
2 Comments
Soorya Prakash
Thanks for the clarification. Can you please also clarify me, if I write the "return" next to invoke line. Will it call successfully the lambda B function and also return executes immediately without waiting for the invoke result.