Package com.amazonaws.services.lambda.invoke
Step 1: Model your function's input and/or output as a set of Java POJOs and/or Exceptions.
public class AddRequest {
private final int leftHandSide;
private final int rightHandSide;
public AddRequest(int leftHandSide, int rightHandSide) {
this.leftHandSide = leftHandSide;
this.rightHandSide = rightHandSide;
}
public int getLeftHandSide() {
return leftHandSide;
}
public int getRightHandSide() {
return rightHandSide;
}
}
public class AddResult {
private int sum;
public int getSum() {
return sum;
}
public void setSum(int sum) {
this.sum = sum;
}
}
public class OverflowException extends LambdaFunctionException {
public AddException(String message) {
super(message, true, "Overflow");
}
}
Input types will be automatically converted to JSON to pass to your Lambda function. The JSON response from your function will be converted to the corresponding result type.
Step 2: Create an interface representing your function(s).
public interface CloudAdder {
-
ClassDescriptionDetermine function name from the
LambdaFunction
annotation's functionName attribute if present otherwise uses the method name.An annotation that marks methods of an interface that are meant to be proxied to remote code running on AWS Lambda.An exception representing the failed execution of a remote Lambda function.A factory for objects that implement a user-supplied interface by invoking a remote Lambda function.Configuration forLambdaInvokerFactory
to override default behavior.An exception thrown if there's a problem serializing a request object to JSON or deserializing the JSON returned by a function to the expected result object.