Skip to content

Instantly share code, notes, and snippets.

@muthugit
Created July 9, 2017 20:29
Show Gist options
  • Save muthugit/8769202b2c669eb3e853a24790fea740 to your computer and use it in GitHub Desktop.
Save muthugit/8769202b2c669eb3e853a24790fea740 to your computer and use it in GitHub Desktop.
AWSLambdaAsyncClient lambdaClient = new AWSLambdaAsyncClient();
lambdaClient.withRegion(Region.getRegion(Regions.US_WEST_2));
InvokeRequest invokeRequest = new InvokeRequest();
invokeRequest.setInvocationType("RequestResponse"); // ENUM RequestResponse or Event
invokeRequest.withFunctionName("FUNCTION NAME").withPayload(payload);
InvokeResult invoke = lambdaClient.invoke(invokeRequest);
try {
// PRINT THE RESPONSE
String val = new String(invoke.getPayload().array(), "UTF-8");
System.out.println("Response==> " + val);
} catch (Exception e) {
System.out.println("error");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment