My goal is to start a Lambda function from within another Lambda function. Specifically I want the 2nd function to start, leaving the 1st function to finish independently of the 2nd. No response needs to be returned to the 1st function.
I have spent a lot of time looking at examples as well as the AWS documentation.
I am able to successfully start the 2nd function but cannot get it run independently of the first. The 1st function always waits for the 2nd one to finish before it finishes.
I use thise code:
AWSLambdaAsync lambda = AWSLambdaAsyncClientBuilder.standard().withRegion(Regions.EU_WEST_1).build(); InvokeRequest req = new InvokeRequest().withFunctionName(functionName).withPayload(jsonStuff); // req.setInvocationType(InvocationType.Event); Future<InvokeResult> future_res = lambda.invokeAsync(req); This does not start the 2nd function (with or without setting the invocation type).
If I include this code:
try { InvokeResult thisResult = future_res.get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } Then the second function is fired but the first function waits for the second to finish before it continues.
How do I start the second function without having to wait for it to complete. At present it ads 2 seconds to the time taken for the first function to complete (the first function, without starting the second, takes 4 seconds to complete).